|
|
百度站长平台链接自动提交-js代码- <script>
2 ^- k! a4 W$ C; g( O( _( e - (function(){
/ n7 |, {. d! j) t - var canonicalURL, curProtocol;
+ {. J/ q" W+ O+ c - //Get the <link> tag$ g& k* N6 @7 `1 m9 S1 b
- var x=document.getElementsByTagName("link");
' \" w# k4 w$ Z# e' A# x - //Find the last canonical URL, j% a6 F9 V: C: Y$ r4 ]9 L
- if(x.length > 0){
2 o, F: U# v6 L - for (i=0;i<x.length;i++){
" A w% `+ n7 F - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
' e! V4 e) P' M3 x+ o( J l - canonicalURL=x[i].href;
5 L7 Q$ e) ]3 G - }
& H' c. s$ h$ \1 e# X. p) F - }2 e" ]; a1 z$ B) Y i3 P
- }
4 [) ~' y1 B2 u( E! e - //Get protocol9 f- G/ C, C" {' `# I
- if (!canonicalURL){0 X; ^6 ^9 I: J) b
- curProtocol = window.location.protocol.split(':')[0];" R( C: Y& L6 z, s+ `4 A
- }' M8 I( O: x# z% d3 d, l
- else{
1 q: u' V7 _& E7 ], Z. ^1 X4 @ - curProtocol = canonicalURL.split(':')[0];7 v6 [- v8 e: c
- }
9 r9 A- O. I0 I& d. S3 { - //Get current URL if the canonical URL does not exist
4 i) X2 C Q" v8 C ^ - if (!canonicalURL) canonicalURL = window.location.href;
) K# H1 j) B3 y1 {7 i0 I - //Assign script content. Replace current URL with the canonical URL! W, x7 {1 _# m/ Z& b7 ^, _! c' 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);})();
9 i- b: X) t, a( Y - </script>
' k, ^6 K9 z: L- x
复制代码
' \/ t$ e5 f- e# h+ G
% z0 n# p$ p9 [4 O1 i' i4 G, a0 s! ^8 z/ @2 ~
|
|