|
|
百度站长平台链接自动提交-js代码- <script>' f9 ~3 R3 I* ~& A4 U' e
- (function(){
1 }- M6 V% Z7 H) C' k - var canonicalURL, curProtocol;$ K2 L f/ e! x T8 l" x( a
- //Get the <link> tag3 N+ |/ Q% {/ Q2 h$ a
- var x=document.getElementsByTagName("link");) ]' r: s3 X" m! ?# A4 F* }& B! I
- //Find the last canonical URL
2 f5 K3 }+ M4 p7 ^+ q) d8 g0 _& m) r% k" K - if(x.length > 0){
0 k0 @% E$ L9 ` - for (i=0;i<x.length;i++){
' v( t5 T, }0 ^! c& z* c - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){! B) o! I1 y0 R' x: ?9 w% l
- canonicalURL=x[i].href;
+ c$ w* [0 E" W! X1 N3 s5 R - }
& p6 z j8 D9 ] W - } U5 J" o9 A3 G6 ~9 f% W1 G, a" y7 D2 O
- }
$ E( J$ I; t9 t! K! g1 p( C4 P - //Get protocol$ g( z% y# {2 }# V" w1 m$ u
- if (!canonicalURL){
H) G4 f0 a) O) C - curProtocol = window.location.protocol.split(':')[0];
, J- A: j0 K* h - }1 H( J2 S9 d% ^/ I1 G/ [* s
- else{
+ R4 k' u8 g( ~7 l: w- z7 P - curProtocol = canonicalURL.split(':')[0];; H2 E# P6 N+ q1 W* f/ d& f% n4 P4 w: g
- }/ ?% C1 s+ Z) M3 v
- //Get current URL if the canonical URL does not exist
( B- Z' |$ ^1 e7 w; Z - if (!canonicalURL) canonicalURL = window.location.href;
6 l/ G6 A2 \4 }- X1 c - //Assign script content. Replace current URL with the canonical URL! p9 s& ~- a: V2 B0 j+ ], y
- !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 {! y, Q/ C, K - </script>
0 s% ^% o, ^+ I6 m, }$ w" R. `: O( H
复制代码 ! E! ~$ P" @1 @) Y1 O/ _, g8 [+ C0 C
0 Y& `3 e' O9 z$ h, f9 [3 \: p4 N% b7 u) P: x" p: q
|
|