|
|
百度站长平台链接自动提交-js代码- <script>
3 ]9 I* p. `3 ^ z! X - (function(){8 h( M. E! ^8 G, I( b( V
- var canonicalURL, curProtocol;: a/ ^ q7 k( |& }+ u7 }6 H, g7 F
- //Get the <link> tag
. g& d7 {+ |5 q: V - var x=document.getElementsByTagName("link");
4 N0 Q- R! P/ A6 M3 v - //Find the last canonical URL. z: _) S! H. X5 h: ]$ |
- if(x.length > 0){
" l. \9 Z, m. c3 t0 U$ U - for (i=0;i<x.length;i++){
: W4 \' y# w" g2 i) A: a4 k- U - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
2 ]4 h a* U+ q' R& W$ F - canonicalURL=x[i].href;* z" R5 d( `' n4 r
- }
6 t. n5 R4 g0 X - }
) M N7 U3 }. [& c& \ - }
. I9 C0 V8 e, f$ ?4 i - //Get protocol8 e. P2 f3 y# ]4 p
- if (!canonicalURL){
4 e* Y( q9 g7 O" r+ s( L) w! T - curProtocol = window.location.protocol.split(':')[0];
L0 M+ ?# c* Y) r - }0 U. P1 W- Z8 a. h0 @1 I; o, [# r
- else{' |/ v9 @: V6 Q& H" R. O" m
- curProtocol = canonicalURL.split(':')[0];
$ b p) F" Y6 L/ n( Q7 u* s - }2 C+ X) ?' W2 L0 F$ ]7 @) F
- //Get current URL if the canonical URL does not exist% ?* N3 L+ a8 H4 ]2 T
- if (!canonicalURL) canonicalURL = window.location.href;
& d0 D- \+ ~: e9 w9 [6 H! a6 K G - //Assign script content. Replace current URL with the canonical URL
- F! ?/ R& [6 T, v2 r! O - !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);})();' C- j8 x# Z3 s
- </script>4 l- P' d- \* X1 ~! P* t0 n6 Y9 e
复制代码 8 v5 D$ m- I5 e7 ?
2 ~9 }2 i; }* j" A9 o" g+ U( Y8 F- \& v& j6 F! m' Y; Y, D( z
|
|