|
百度站长平台链接自动提交-js代码- <script>8 U1 `) P* ]/ s5 `/ J% N
- (function(){4 H$ x2 z& ?- g; X- N/ ^# b
- var canonicalURL, curProtocol;
, T! o& D. ^% t8 Y& J) M0 l - //Get the <link> tag
- {8 _+ O" i/ i7 _ - var x=document.getElementsByTagName("link");0 t/ Q& v1 b- |) X2 r- c
- //Find the last canonical URL' n3 m" P, z- d* Y
- if(x.length > 0){0 B$ t% d T* C$ v/ `' c
- for (i=0;i<x.length;i++){/ o# u6 t% r! Q! i
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){3 e e* i' I/ B7 N3 d$ n9 F
- canonicalURL=x[i].href;
6 D! G3 Q/ r0 c3 L% y1 _) N - }
$ y) T; ?6 ~) \8 J - }
7 W& R' f8 L8 E/ x/ V - }! o' }2 v& c* d' t: F
- //Get protocol
0 u9 U( k( @" R% f( T - if (!canonicalURL){
% j( y. `& n/ s/ f% g6 p @7 g - curProtocol = window.location.protocol.split(':')[0];
6 g4 q+ `5 c' p W% K - }0 U" R* C7 R+ N D6 G1 X2 ~" J) Y
- else{2 `0 X) _9 y& C
- curProtocol = canonicalURL.split(':')[0];
: _6 \$ ^. w% D! }) A/ b6 f) } - }
+ i; c+ Q, \3 y( V+ r# E - //Get current URL if the canonical URL does not exist J* C A ?) w& b( k
- if (!canonicalURL) canonicalURL = window.location.href;
! C4 p9 S- \+ U& J - //Assign script content. Replace current URL with the canonical URL
5 T Z# _ [; w5 @! p2 y% l* s - !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);})();
a. _" w' l& z - </script>
% W5 {$ ]: R O0 i4 w+ Q n+ V
复制代码 ) X. u& T# a2 w. i
! P0 m; I! _- K; j% ]* `4 U( }" q3 j
|
|