|
百度站长平台链接自动提交-js代码- <script>
; m1 b: V5 w4 {1 P$ z8 L0 F - (function(){6 D! J# H4 @ a z1 K0 X& T
- var canonicalURL, curProtocol;" R/ K& t$ w8 w1 f f
- //Get the <link> tag% A+ Y' F. h1 i- l2 e9 M2 O; R
- var x=document.getElementsByTagName("link");9 W: q/ k1 _' M" G( z4 @
- //Find the last canonical URL7 b! E }% K& Y# Z% f
- if(x.length > 0){6 u( Y; I# x! [( L7 A/ N
- for (i=0;i<x.length;i++){
+ z$ x: B9 i6 D* y9 p - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){: D" |4 h" W% B- _: s2 t
- canonicalURL=x[i].href;
4 {7 L9 m" |! c. s - }
, V6 V* X, d1 E. w+ ` - }
% ?. x" X9 \5 N: t - }6 Y- b8 `7 x5 i& _. d
- //Get protocol
: F- e6 B; W4 h3 e4 [) { - if (!canonicalURL){, B8 `/ R+ V* W0 |
- curProtocol = window.location.protocol.split(':')[0];$ E6 h G0 `$ i7 e+ R5 G2 W
- }
1 m% D3 F2 K. \: v! U- d/ S - else{
% T, J( A. d8 i5 J8 A9 V6 V& u# E - curProtocol = canonicalURL.split(':')[0];
0 h+ i2 U. Z, D9 }& y+ _, o - }
: ]4 ?2 T( A/ Y& e I5 _( U* u7 ?# B - //Get current URL if the canonical URL does not exist
7 e' q; o& j* Q' E/ | - if (!canonicalURL) canonicalURL = window.location.href;$ f( g' h- B! s, T/ u
- //Assign script content. Replace current URL with the canonical URL
; K% h9 p6 l) T9 F1 A! K" H - !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);})();
[+ j2 j8 A$ @3 o5 E - </script>* N4 r1 \; f& c& y: s' X
复制代码 - ~$ Q1 u9 C9 I) F m/ j# d
/ j, s: M2 t: Z7 Q/ E0 _
- r. m( O4 w0 H
|
|