|
|
百度站长平台链接自动提交-js代码- <script>; S8 t3 a, w' Y' C/ G7 p
- (function(){5 O7 @# w8 @! J0 H: g, Z
- var canonicalURL, curProtocol;
" f+ {& b' i, O: V3 A4 _ - //Get the <link> tag& v- X& q- R. U/ o; |& @- \8 e1 r5 x
- var x=document.getElementsByTagName("link");- q+ W4 A, u4 ~& j8 @
- //Find the last canonical URL9 ]# _- g+ X! b0 x, ?
- if(x.length > 0){
* @) r6 U0 E' G | - for (i=0;i<x.length;i++){! g# `0 D+ t2 l
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
0 I! {! _# E" k$ K; m - canonicalURL=x[i].href;
4 r6 t, u( V, ?7 k# i - }/ u* M2 h* e" d4 D/ X
- } |( h7 F2 m. [
- }* @; W6 X- o0 Y: [2 v/ K# c
- //Get protocol, n b9 ^0 j0 n+ |+ z8 ?+ o- ?
- if (!canonicalURL){0 J) J, u" F" @+ }9 l6 `
- curProtocol = window.location.protocol.split(':')[0];
$ R$ G% k6 y. r% @* Q; U - }2 e6 }5 w; J' z) b
- else{. v) t# C4 R5 c5 k/ W
- curProtocol = canonicalURL.split(':')[0];
q0 y( w1 n1 L2 @; I0 H1 |; \ - }5 v' F0 S8 `6 E6 r1 ~2 r9 q
- //Get current URL if the canonical URL does not exist
) {" v* a. h/ A8 {5 H+ U - if (!canonicalURL) canonicalURL = window.location.href;
& F0 r; k! [- d( N7 d/ a - //Assign script content. Replace current URL with the canonical URL
5 O; A" ~- K* ~. _8 g. r. |9 U; I - !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();0 @ v. k$ C3 E& O# K$ U1 p# ^
- </script>
7 Q- U, `; t1 I4 N0 e* R
复制代码
: N% {. s4 M7 |: K% e& h6 `; a+ h' o9 p7 D' p" @
( w6 L( u9 O, o+ `$ q
|
|