|
|
百度站长平台链接自动提交-js代码- <script>: ]6 y/ R1 M- i4 \( t' U' ^
- (function(){0 ^, L9 {' l6 X. p' t% w
- var canonicalURL, curProtocol;. L2 I) z* r& m% K
- //Get the <link> tag
& N! c! O* S4 I B* n - var x=document.getElementsByTagName("link");
. B z3 ?% a" Q1 Q" G" H5 W1 } - //Find the last canonical URL
6 r _! h& g) c- O/ D; P" h - if(x.length > 0){# S. f5 t9 b r1 J4 j
- for (i=0;i<x.length;i++){
! {- K+ p* @# ]: g" M. w - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
* Q- F# n7 N8 S+ F0 M0 f1 n1 h - canonicalURL=x[i].href;+ K0 Z0 P) J& x
- }* A- e6 i, h4 ?
- }8 O3 j. b$ C; G, R: e
- }, m2 [6 ]0 m9 `
- //Get protocol
/ r& i6 N. w% U" { - if (!canonicalURL){
% e% ~5 M* p8 N9 o# B+ s, e$ Z - curProtocol = window.location.protocol.split(':')[0];
0 y/ H4 ~/ I3 j% c - }, `7 U" l9 Q" r1 y+ T% |" `
- else{
' T3 Q8 M# F1 ^7 R+ n9 w1 E - curProtocol = canonicalURL.split(':')[0];
! d J8 T* D0 b" a - }
+ q5 [: H) r% ^: M# z1 Z L - //Get current URL if the canonical URL does not exist9 ^" `+ z0 P: b. h/ w: R# r
- if (!canonicalURL) canonicalURL = window.location.href;, Z: }& g- _% R3 b5 X
- //Assign script content. Replace current URL with the canonical URL: M; o8 R- F; |" h2 p/ g6 @
- !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);})();/ L9 r* Q3 s- T2 \6 q/ X1 ]+ Y
- </script>% l# o# V$ z- F; r/ w, [
复制代码 3 T( B6 N$ `8 s0 j/ f" |
' o, N: C5 ?5 M8 [) j* l* U; Z R+ Q9 H& b
|
|