|
百度站长平台链接自动提交-js代码- <script>
3 x- o' l: _) J) p% u: c - (function(){1 p8 b- C; E) c% J: {. ~- q
- var canonicalURL, curProtocol;
4 \: V& k1 e& h4 C+ }( v - //Get the <link> tag. Y9 d4 T4 K a. ~) g" x1 o& M) p J
- var x=document.getElementsByTagName("link");. b% Z2 K9 d+ D. g0 u3 c
- //Find the last canonical URL* v$ ~0 N) _- ?8 Q) F8 \
- if(x.length > 0){* {3 P. p4 K) I( D7 `5 T
- for (i=0;i<x.length;i++){) i8 L# z! n1 @
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){9 N3 s1 n, P- j! @
- canonicalURL=x[i].href;
5 P& h& j8 U$ J' h; U% b" e - }* E; B# o# q0 v- ?' K
- }
4 q8 T) W3 x/ o$ U! B - }
, g, o8 v' R/ C4 }# \& `& t - //Get protocol- ]8 t; f. ^* I$ T: @2 d
- if (!canonicalURL){
, Q% |! `" j9 ?* {! f1 {4 w; Z - curProtocol = window.location.protocol.split(':')[0];8 \+ j# l' W) `
- }
0 C9 m7 D. _9 H - else{0 a S3 w+ k3 E! b# Q
- curProtocol = canonicalURL.split(':')[0];
7 E8 j. N C9 Y0 g - }
& m' J4 e8 r" u& G3 e* ` - //Get current URL if the canonical URL does not exist
' ]; [( x* W7 _' V8 b* n5 R# d - if (!canonicalURL) canonicalURL = window.location.href;
% k/ _ q: I } - //Assign script content. Replace current URL with the canonical URL
: l/ A) ]" E+ o" d- n - !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);})();
' J4 H3 @9 `! y - </script>
7 a7 n/ R5 i2 B* V2 d
复制代码
( F [% _( M6 j' Q; k ~1 w$ Q3 T- I( V" D& G6 o0 W/ _( y+ W
2 V7 e' e+ R4 s, u) P7 R! \ |
|