|
|
百度站长平台链接自动提交-js代码- <script>. L* l+ N5 \" E
- (function(){
# e$ }3 k' l! Y: q( p, q - var canonicalURL, curProtocol;5 L% O4 u# ]* m
- //Get the <link> tag
$ s. c3 m% d( G- |9 y - var x=document.getElementsByTagName("link");* h+ S5 q. L" j d2 p5 m8 |3 `
- //Find the last canonical URL3 j6 z' o9 j# ^2 C+ Z
- if(x.length > 0){
! y& W8 W9 |5 n# |+ @ - for (i=0;i<x.length;i++){, v6 o( n2 k: D/ w* w; D
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){& p& f; }7 g# @% S4 ? |8 w2 z9 h
- canonicalURL=x[i].href;) y/ G; \9 ]" t5 _3 ~
- }' C' u, R' m" C6 Y5 q
- }
: E J, m* C9 I& ~7 A - }
& v! B) q [7 @0 r" @8 Z; F - //Get protocol% D, f7 c4 v3 N, \! f
- if (!canonicalURL){, e) s1 Y/ c. n- v1 ~! q% b
- curProtocol = window.location.protocol.split(':')[0];
8 X9 ~# G2 p( D! S6 N, J* X - }
; A! T) q& B- } - else{- B! s) y n, P- W
- curProtocol = canonicalURL.split(':')[0];
9 W3 o: T3 ?/ X' f7 G - }5 \0 u& ]) C6 I2 o
- //Get current URL if the canonical URL does not exist
: \, {. B; V2 h U9 P - if (!canonicalURL) canonicalURL = window.location.href;4 Y" ]% z8 ~7 z2 _/ E
- //Assign script content. Replace current URL with the canonical URL0 v6 q8 [. D* }8 Q7 Q% ]/ l
- !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);})();
. Z6 N7 }# [6 N - </script>
; p/ c9 o) Y! P' l0 D( h
复制代码 ' [- E2 T& Y, C4 ?( d
9 Q4 F: R. q# I- t/ a, p2 y3 w: f6 U% Q, w5 B6 B6 G
|
|