|
|
百度站长平台链接自动提交-js代码- <script>0 ?# _) b) {; Q
- (function(){
) v/ [" O( k1 g' ?- X7 r - var canonicalURL, curProtocol;5 y1 @+ v3 ~" _$ @2 \
- //Get the <link> tag
. A$ z7 }* f' |: u - var x=document.getElementsByTagName("link");
- C5 T& p5 H' r - //Find the last canonical URL
$ U L% m8 V* u - if(x.length > 0){
. e0 a: Y* v9 U5 K - for (i=0;i<x.length;i++){* @) l s t- k' K/ B4 T
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){6 _ W; a' L/ V2 ^3 [$ s, m: z2 L
- canonicalURL=x[i].href;$ f6 V# q. c6 g: K$ |' I
- }
]9 K/ ]" H( M; E% {4 V" b' \5 j - }
' `6 `3 l, T6 w( G0 j6 @5 { - }" Q5 D! e) w- ?) \ {
- //Get protocol* S) U1 ^. T! ]/ E$ [
- if (!canonicalURL){' R6 Z7 {7 l' x1 N( ^1 H
- curProtocol = window.location.protocol.split(':')[0];
7 Q, K( f7 ^1 q* A - }
0 e1 z8 B( Z/ p: n7 _8 C - else{
( x8 t4 j2 M" [/ y1 T - curProtocol = canonicalURL.split(':')[0];5 ?' S' O! u. _4 s+ C& ]' A# H
- }. q& @4 ]' i9 e) e3 n& E. ?+ `
- //Get current URL if the canonical URL does not exist4 {3 s8 J5 t' ^, |( Z6 i: `: P
- if (!canonicalURL) canonicalURL = window.location.href;
$ [! V0 Q3 r- b$ W! r - //Assign script content. Replace current URL with the canonical URL" b7 J6 {- Z( W% ^4 R
- !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 B1 d o; M/ B8 z
- </script># {; E6 W6 V1 A* l* [+ w
复制代码
0 ]+ Q2 o: D6 J0 V' x, h
: E# ^9 {, e! T& S# t) E$ G' p5 X7 B' w2 }
|
|