|
|
百度站长平台链接自动提交-js代码- <script>2 ?2 b: [$ S( K H" J& H
- (function(){ s; E3 d" l8 x9 @4 E1 u
- var canonicalURL, curProtocol;
6 p/ r4 [, S1 N% v! p - //Get the <link> tag
% ^9 Z, d5 l* {1 z. P - var x=document.getElementsByTagName("link");7 s7 \; T# C9 z2 e$ y
- //Find the last canonical URL
T v( A) o; C - if(x.length > 0){ }6 Y/ c. Q( O+ @% g- y+ z, S
- for (i=0;i<x.length;i++){" K8 j, \9 j2 [2 ?
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
8 c# O/ e a% Z w3 R - canonicalURL=x[i].href;
' }/ r# k) V$ j* l! A& q - }
& x i/ z( r0 I/ d - }) x. w M, }/ e% D- {$ S/ }9 O, D- s
- }; l7 y* ~9 S7 o3 `- E, R+ z: T6 Y
- //Get protocol4 z G- ^: H) e1 ], ^/ f7 f
- if (!canonicalURL){
; A6 l) ?/ i7 l% b0 n; f- e/ X - curProtocol = window.location.protocol.split(':')[0];" t! i8 U! l) f9 d% ]
- } C0 k7 q2 ~1 G, v' I
- else{. p% Q( c) C, F9 O4 t5 L
- curProtocol = canonicalURL.split(':')[0];# F, x. N& Y- G/ ]9 ] M' u* ]- u6 a
- }. F2 N/ I, J; I) | |
- //Get current URL if the canonical URL does not exist7 F- V7 O' q6 o
- if (!canonicalURL) canonicalURL = window.location.href;/ p1 w5 A* k) @" [: t d/ ~) e
- //Assign script content. Replace current URL with the canonical URL3 X- V9 K7 E0 C2 _
- !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);})();
- e' f! S* U& K0 R( g" ? - </script>/ C w! u5 W5 X3 Q; c2 ^$ x
复制代码 {5 C% a$ o, _3 H/ Q+ K: ~
4 E$ N2 @5 B, p: f9 ~
8 g' C9 S4 y7 f
|
|