|
|
百度站长平台链接自动提交-js代码- <script>' t6 b5 c1 k6 [0 [+ G/ d
- (function(){) D: }0 \/ I8 r' E$ s
- var canonicalURL, curProtocol;6 \* o; e( [( X1 g' Y, U
- //Get the <link> tag
/ {: [/ x' V& R+ C1 e - var x=document.getElementsByTagName("link");6 o6 R- `6 C8 T* W
- //Find the last canonical URL# d& \+ P# A: R
- if(x.length > 0){+ m0 D5 E4 L0 H$ B8 ~5 F0 V$ V
- for (i=0;i<x.length;i++){. O& m0 P3 Z: c; Q* P
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){! K2 @ w& r" V0 z
- canonicalURL=x[i].href;
1 @* U1 L& I, O* Y# K# e x - }
7 P! p: ?) V% p- @- o& ]1 u - }
- R) F2 `; k& U2 k/ M - }: d4 X$ T, I: @6 Q
- //Get protocol' o. ~: M! w" T$ E4 P3 v
- if (!canonicalURL){
, u$ h- N! d$ G% x4 R5 d, p - curProtocol = window.location.protocol.split(':')[0];
) [% p" K! W' L y7 ]7 ~ - }" d! [" g4 x( a: }; f- v* l% R
- else{5 y" `0 R1 I- E% ^+ s
- curProtocol = canonicalURL.split(':')[0];
( U3 Z6 \8 M9 ]" ^5 l0 u3 h - }
: k8 I% c4 G% q - //Get current URL if the canonical URL does not exist
7 T/ M* R0 {; z9 w4 |5 A, E/ g9 H - if (!canonicalURL) canonicalURL = window.location.href;: d! z* Z, n. {8 H+ J; l
- //Assign script content. Replace current URL with the canonical URL
9 r P& V& ` x2 J" Z$ Y8 w$ P - !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 v) l* h, j. |$ ~
- </script> v5 F( |1 K9 S1 G" N \6 c$ q5 Y8 O
复制代码 * L& E4 {; @. R: m
2 j& k9 v1 c ^. s5 t& H& z! F; T' W& Z( P) V
|
|