|
|
百度站长平台链接自动提交-js代码- <script>5 f4 z7 W4 M+ K( |. c
- (function(){! ]9 ?+ R2 t: B" [
- var canonicalURL, curProtocol;
; J( @+ q7 G/ B4 Z - //Get the <link> tag% p: J Z& v& }6 k$ K% j
- var x=document.getElementsByTagName("link");- \7 [/ t( L2 `
- //Find the last canonical URL/ }: M/ u G3 x' a; j7 D( d
- if(x.length > 0){' p' H1 \3 T- r% Z3 g1 m
- for (i=0;i<x.length;i++){' q b* \$ W9 [3 u$ L
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
) G) l; Z: u+ X" c V - canonicalURL=x[i].href; {2 _9 n* y7 h
- }8 @4 A5 f2 _/ ]2 C7 t0 _& L4 ]& E. I
- }
/ }8 f& O" h6 u+ d6 S& }% w - }
6 U( S3 v* {% g, ~7 P) M+ C - //Get protocol
7 f( [: v: c k4 j6 [7 ?* j W$ { - if (!canonicalURL){7 ^* o9 b8 F3 t
- curProtocol = window.location.protocol.split(':')[0];. I/ D! e6 r: ]: [) ~$ x/ D
- }
0 ^( R4 l! [# l4 j- Q, U) L6 ? - else{5 S" O8 a6 R: y J4 e6 a. B3 u
- curProtocol = canonicalURL.split(':')[0]; i2 }4 Q' s; V3 m4 ?1 y
- }( w E$ r( ~6 b9 H
- //Get current URL if the canonical URL does not exist
% ], ]4 }$ H$ ?' {# g9 R1 \ - if (!canonicalURL) canonicalURL = window.location.href;
7 V6 k; `7 H$ q' U3 C) w" | - //Assign script content. Replace current URL with the canonical URL
3 n" ?! R/ k2 u6 T - !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);})();8 E# C4 P7 y' o; ^/ q
- </script>) q1 ^' x9 v- Q! U
复制代码 2 s$ r0 Z& a# |, Y3 y) k$ a
2 V7 ]9 X6 Z5 c# s+ E: ~3 p5 @
( P8 K# ]7 q! |( L! Q$ S
|
|