|
|
百度站长平台链接自动提交-js代码- <script>0 r+ ]2 e- ]# I2 h! J
- (function(){* d5 o9 {) M- ?% Z
- var canonicalURL, curProtocol;
" E f& V2 h G% U" M% D - //Get the <link> tag9 C% a( [1 O1 t) n1 a, U0 z
- var x=document.getElementsByTagName("link");/ b* s$ g9 y: F9 \/ R$ p
- //Find the last canonical URL) \! g( Y2 J3 r' M/ R; C
- if(x.length > 0){! l! I+ \/ C/ O4 v
- for (i=0;i<x.length;i++){1 T) B" ^; A, N b
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){4 |# r2 ^- i$ r7 \: H
- canonicalURL=x[i].href;
, h% f( m v# F7 m- L5 j - }
" J/ j/ {1 ]4 m! f c. { - }2 J6 l8 V4 n# e' D
- }
2 f6 z& i( F7 [5 l4 ~- l- ^ - //Get protocol' \- T" `% x4 H$ F5 z
- if (!canonicalURL){; y- l; ~+ h2 t8 |( \3 ~& X/ Z4 N
- curProtocol = window.location.protocol.split(':')[0];
( _) P( M7 `% `; H; B' K: W% ^9 i - }
8 ?; O! N/ V! O" c - else{- u1 U9 [" X0 K9 a0 I$ g u% E4 `/ P, e& \
- curProtocol = canonicalURL.split(':')[0]; r4 H9 i3 w, p; D: @/ u+ S
- }
' ^: @" F8 x9 `" z/ s - //Get current URL if the canonical URL does not exist. @5 Y- B3 T' y0 N- ]- E9 n
- if (!canonicalURL) canonicalURL = window.location.href;
. X' ]% v. q8 V' G0 b% C# ]; P1 i8 h9 t - //Assign script content. Replace current URL with the canonical URL
( s- B9 g" u5 |, Q9 | n; X% c0 N5 G2 s* X - !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);})();/ \* K. j& n% |& b
- </script>0 [6 A1 N) z1 I7 M1 g
复制代码
1 x6 @* a# ]) q! Y1 A
4 \9 x6 N8 D9 A. i# h9 B/ K% [
6 Z8 {6 L* f: }. ` |
|