|
|
百度站长平台链接自动提交-js代码- <script>% p' @0 S, s3 k' u+ {
- (function(){3 U7 ]1 \0 w$ T! S2 w6 ?( A
- var canonicalURL, curProtocol;1 j6 J8 z7 e9 B4 u7 w
- //Get the <link> tag
7 T: R. A2 M& ` - var x=document.getElementsByTagName("link");
2 n3 R) `' g- S; k$ X - //Find the last canonical URL
$ k% P" I/ M6 B8 Q" e5 _$ F4 o& r - if(x.length > 0){! ~! |, z& x3 _$ d
- for (i=0;i<x.length;i++){3 I( [8 S6 g# q$ d7 }6 q" B
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){# F* F r1 x1 C8 M c5 b0 d" D! D
- canonicalURL=x[i].href;5 n( c! ^! M' i% f: h: B' w
- }
/ U# `4 f! n* N- V' Y - }
8 t f4 q9 g5 d% j, Q - }5 d+ u. C8 z- ?7 u: K
- //Get protocol
' E) C" p& W/ [' w% R7 A - if (!canonicalURL){
1 V' ~/ A& L! @1 L I8 p - curProtocol = window.location.protocol.split(':')[0];" [; |( k/ M5 Z
- }& `) Y0 Q! y0 `
- else{
+ K3 j$ d; h2 g7 ?8 k! u - curProtocol = canonicalURL.split(':')[0];9 d% f, l8 \0 U
- }
0 v M$ k+ Z1 b6 H - //Get current URL if the canonical URL does not exist
$ E, ~( z5 L6 @' E$ E& Z - if (!canonicalURL) canonicalURL = window.location.href;: n) f; J7 M' h, M& b# n
- //Assign script content. Replace current URL with the canonical URL) f6 R+ P- w2 R; H/ ~) U
- !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);})();
# ~. ]6 L; l! g; T# a. } - </script>- L9 i) P! t' ^$ z& ]" m
复制代码 ! O% D. n( t# q; {* M U) p
X' Y3 H! G1 D9 ~
( t% \ \/ Q( I% ?! g |
|