|
|
百度站长平台链接自动提交-js代码- <script>
2 n0 J0 e E5 \ - (function(){
8 b/ t8 o" f+ E9 ^) i# J: y1 s - var canonicalURL, curProtocol;9 R- E6 j u7 l7 x
- //Get the <link> tag, ?. H, o2 ^6 b, w- b+ O5 m
- var x=document.getElementsByTagName("link");
: g" r3 n. c( K: m0 {2 t) B3 m5 l - //Find the last canonical URL; j1 @* R; |5 x& k/ x4 S2 I
- if(x.length > 0){
1 ]7 ^* T- ^9 A% G5 T - for (i=0;i<x.length;i++){: t, H, d+ l2 e0 M
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){) o+ J' h" `! u/ e/ J P0 D7 X
- canonicalURL=x[i].href;. g) `* x) m* w: I3 V2 m+ e8 G0 y
- }
4 s8 O) T; l) _" s; q - }4 L; T) Z+ E9 N" d& h2 y+ l1 }1 r
- }$ j3 I& q1 h6 s$ f8 ] E& }
- //Get protocol& {1 }1 ]. s3 m' k- M7 k: i" [$ Y
- if (!canonicalURL){* {- o7 @. m/ I% V
- curProtocol = window.location.protocol.split(':')[0];
e" i9 n* ~4 b3 A+ U( Q& W- R; u - }
2 V/ F) Z: M* y j* l - else{
$ J( i# f/ A: V2 u$ b+ [% F# g - curProtocol = canonicalURL.split(':')[0];% L. B, p3 ]7 K& _2 h
- }
" }+ e( K' m% k* D: t; l; G$ u- y - //Get current URL if the canonical URL does not exist# L2 j( P9 D- V- N1 W/ o0 _
- if (!canonicalURL) canonicalURL = window.location.href;6 k7 N ? `4 }5 Z
- //Assign script content. Replace current URL with the canonical URL
) m! K$ C3 \! q% D - !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);})();! u8 r; O; \$ X$ Z2 l5 u
- </script>
$ Y/ \( u0 j* j. {2 ~& j0 I
复制代码
) y8 y0 k' _, t4 S; T- r' V1 f) \6 ]7 B
, U& w/ Q: l. x, j& O8 ?; Z |
|