|
|
百度站长平台链接自动提交-js代码- <script>0 E, P! k: s" y2 D# M8 ^; N* W; X
- (function(){* E) X9 G! h$ J$ M$ y, H7 r
- var canonicalURL, curProtocol;% `0 q; @, c3 ]. J E
- //Get the <link> tag }7 n2 x! h4 ?2 B" ?( @: K
- var x=document.getElementsByTagName("link");+ c4 L: y8 C" t5 l1 L" {# R! N
- //Find the last canonical URL4 p: ? ]' Z, p+ ^+ ]
- if(x.length > 0){- s r) S/ X$ w- q; \7 i& f9 L
- for (i=0;i<x.length;i++){0 j5 r' v) P) x1 F( ^3 x
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){8 k' h+ P" E" x! h0 r" q
- canonicalURL=x[i].href;
0 k/ u! O# ]! H - }
( u6 z/ G. P. g0 y - }
8 c" S3 ~# w4 \, k$ Y, y - }
. [/ y5 }- F" W! @! w; B" ` - //Get protocol
: _& u3 r% F" y - if (!canonicalURL){$ A& \2 v: f* Y: w1 S9 i! G
- curProtocol = window.location.protocol.split(':')[0];: E- X2 d0 A5 i- Y/ Z# \1 a
- }0 K( j7 B; y3 p. X2 s& a# i+ U
- else{
/ e9 u' ?$ M- D( @; ~. {) e - curProtocol = canonicalURL.split(':')[0];
, ~0 a2 N- ? `: ]# E, ? | - }# q4 e0 O" Z9 X/ h% w7 q
- //Get current URL if the canonical URL does not exist9 V/ ?1 k; N2 {4 J" K& l! a
- if (!canonicalURL) canonicalURL = window.location.href;
. y8 z& ]/ I Z; W( e - //Assign script content. Replace current URL with the canonical URL4 L- i! H+ s4 k1 N, ?. M' 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);})();
* E, M! m! g; b3 q8 [! \* C - </script>" r) Y4 e1 h, J( [+ q( `3 [
复制代码
( |# ^6 }7 g5 d# |$ x, F) B6 B+ r0 ^9 Z2 `! F$ ^" @
" t" m/ W7 U3 ^) e+ z |
|