|
|
百度站长平台链接自动提交-js代码- <script>
; P+ c8 ]. F8 C, w - (function(){
- ]$ F! t# q# Y: F8 f$ v o - var canonicalURL, curProtocol;
9 p4 L) _9 l( ^/ ~1 e - //Get the <link> tag0 A! a% _/ c% |0 H: l( q$ E
- var x=document.getElementsByTagName("link");
5 f! [ }. O( e8 S- b# }3 F0 [% I - //Find the last canonical URL& G' `/ x" Y: M! p4 w
- if(x.length > 0){
1 @; c, `6 g' |( ]4 ]8 F I7 k - for (i=0;i<x.length;i++){
' S; ^) x: L: \" Y0 x' @; j - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){' \, B/ }0 K" B! }0 ]
- canonicalURL=x[i].href;
! B3 z+ @" I' }- f3 Y) { - }5 g% G, i$ {9 i/ s0 ?1 X% |/ k# j
- }
) I) Y# I# w2 f- N. t7 w - }2 ~4 Y5 W6 U7 p. B( l3 K- G
- //Get protocol( S. J9 H9 s9 X+ R; P
- if (!canonicalURL){: N0 u: k9 M; k/ c5 T+ R
- curProtocol = window.location.protocol.split(':')[0];
# c; v2 ^3 [6 Z - }0 p: i2 |+ L' [/ m/ ~- J
- else{
5 V% _4 V; v3 w - curProtocol = canonicalURL.split(':')[0];+ e! G; c1 ^+ M# g n
- }
# ~& c1 X/ P2 } b - //Get current URL if the canonical URL does not exist: r# P: T* _# @; F: E/ m* \
- if (!canonicalURL) canonicalURL = window.location.href;
: g" o( G' W4 _# h# E& W - //Assign script content. Replace current URL with the canonical URL9 }7 ^4 G% J+ S) {1 }. F; i
- !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);})();
. m9 l" i5 e( \0 O - </script>
( H1 g4 g! u5 k3 m
复制代码 " }* L+ y) w/ I T* k
a# I8 a! P U* H/ `# P1 }+ H7 @ m
5 w- x- H1 }) W
|
|