|
|
百度站长平台链接自动提交-js代码- <script>
+ g) t2 x. }8 E: f - (function(){9 J% a/ I2 X6 z9 I$ Y4 p
- var canonicalURL, curProtocol;
. P; j# e3 V; w. H1 V - //Get the <link> tag
V- H/ n0 B, K5 H. z - var x=document.getElementsByTagName("link");: E4 v) Y' @8 \
- //Find the last canonical URL
. r0 r3 t3 |9 }& x5 R! I: Z - if(x.length > 0){: y" S; H. j" } i6 X: H) j
- for (i=0;i<x.length;i++){
! q* ?2 e: w& y, o1 q" K+ p - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){+ \& h+ i. y5 B9 B
- canonicalURL=x[i].href;
# F" u6 }7 }2 k8 m! S& E1 q - }- V7 |) Q; O d" Z. _) J% ^
- }4 a* F: b" A, @7 \; |6 ?" n
- }; p5 E8 j' B1 w
- //Get protocol
! |% N. a4 j& p; O7 p - if (!canonicalURL){/ z2 z8 I g2 s z+ d
- curProtocol = window.location.protocol.split(':')[0];
1 l6 [6 H# g* m( _2 s - }
4 E: Y3 }/ Z8 A4 _9 Z% M' ~9 P - else{
) P& Y1 O+ Z* K( {# M! X7 r - curProtocol = canonicalURL.split(':')[0];% O W* M: p- w. u
- }
) C, X. V+ G! y - //Get current URL if the canonical URL does not exist2 j) M" T4 X* W9 i
- if (!canonicalURL) canonicalURL = window.location.href;. I/ y/ w/ B) |3 o& W9 C1 `
- //Assign script content. Replace current URL with the canonical URL) F& a" T, z- f0 O
- !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);})(); ~9 ?) R) V6 {) T
- </script># M, q6 T! s* d# ~
复制代码 7 J1 o0 S2 U$ c5 {1 o, D0 p
% `) d! g5 _1 n
" n6 n* T; L5 g: g3 X V |
|