百度站长平台链接自动提交-js代码- <script>
* x( D# Z& _7 V% w - (function(){1 q( f Z9 v' G. T. F; u
- var canonicalURL, curProtocol;& a* T( S% z4 M. i2 K
- //Get the <link> tag! |; v3 V% ^, I- e
- var x=document.getElementsByTagName("link");: E5 s3 I+ o) p& K, k) M8 x
- //Find the last canonical URL/ _% z9 `$ G2 d- V
- if(x.length > 0){
, _# {7 Z- y# G5 J" s - for (i=0;i<x.length;i++){
* K7 g" f2 c, C+ I& w( S1 G3 [ - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){5 H3 z' {& B0 K2 f8 l8 y
- canonicalURL=x[i].href;) `' O- b9 S8 {3 | G* [& f1 C
- }
/ p, w% L2 p& z7 s9 s" q0 O - }
$ q0 Q, S" v" L - }4 x2 k& Y8 s0 B
- //Get protocol
5 [3 P- i& X# Z; N - if (!canonicalURL){
3 z* x4 A, [, }3 A: V8 L, V - curProtocol = window.location.protocol.split(':')[0];
5 b* N: q" I7 J - }
6 f+ M' }" V ~. U - else{' z6 H2 v* v: F3 D% V! b
- curProtocol = canonicalURL.split(':')[0];
# Q/ O9 n0 P0 W; x* m# R7 I% B0 k - }, d/ V: v: F/ v! N0 y2 ~4 y
- //Get current URL if the canonical URL does not exist
3 S* ?" u0 _1 q8 P3 n, f - if (!canonicalURL) canonicalURL = window.location.href;
$ p0 h! S- b6 J* ~ - //Assign script content. Replace current URL with the canonical URL
8 R5 ^1 g: F4 F& } - !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);})();
+ S; A; S- o, M4 P% E2 C6 k - </script>3 l: s# s, s) @. z, K; I
复制代码 + a/ W- u* x9 a$ x3 l+ A; d
# g2 P, g* R2 f: }4 b' k
0 m f$ k. o \* M/ Y" i; G: u/ d# { |