|
|
百度站长平台链接自动提交-js代码- <script>
7 B. L# C% E* `" j; l - (function(){
! J3 o# L' f( P* g7 @6 ? - var canonicalURL, curProtocol;
T: T4 @% [: R' z, P9 ^' H - //Get the <link> tag
/ N' u! `, e' k' j2 h8 M - var x=document.getElementsByTagName("link");
8 W- }1 q7 C" Z - //Find the last canonical URL/ U2 s: q8 g0 X& ~4 m& w
- if(x.length > 0){5 `$ T' W8 D( z+ q
- for (i=0;i<x.length;i++){1 w1 R0 J8 b' I( Y5 m$ i
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){' J) |0 o+ a! L7 J- r: n
- canonicalURL=x[i].href;
! l1 z0 n7 S. I' y. l! [ d - }" g7 z: T4 Y. W9 z
- }
0 ~3 S( k) K# M2 x! ^$ _9 Q - }
5 [* @' ]" }' B6 D - //Get protocol+ ^ q% h7 M! i, B6 t% u5 T
- if (!canonicalURL){
$ T3 d Z: d7 j; R) K4 `; v8 O3 P - curProtocol = window.location.protocol.split(':')[0];7 ]- N! l- V5 h; { u& }
- }0 i# n7 \# X0 M3 w6 ?9 n
- else{
5 @' o* @+ [7 M3 E' _/ p) c - curProtocol = canonicalURL.split(':')[0];
7 ^! F' e# }( d5 _8 E. T5 N - }2 s& F1 F% I/ V' P( a4 f
- //Get current URL if the canonical URL does not exist
Y3 q) I$ K1 q* r - if (!canonicalURL) canonicalURL = window.location.href;3 |& I- B3 ?6 c" z2 F2 z4 Z
- //Assign script content. Replace current URL with the canonical URL
+ h" n5 ]: |1 `% O6 ~+ t - !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);})();7 O3 }$ T5 ?( u' ?: u6 l3 W/ B
- </script>, w0 {7 N0 l, _
复制代码 " |9 o- M; q9 |, f- ~4 n! j
& y% c# C1 g" o3 k. O0 P
, Z$ R/ c5 ^1 J# T: |
|
|