|
|
百度站长平台链接自动提交-js代码- <script>
& ]5 X5 b# C7 |' T - (function(){: w+ w! l& d* k$ M
- var canonicalURL, curProtocol;
# X9 d' [/ O5 B% N- u3 I9 c8 E$ o - //Get the <link> tag6 u4 D/ I4 d$ K* B" U
- var x=document.getElementsByTagName("link");
1 a- K+ L+ p& S1 b- ~5 l - //Find the last canonical URL' S' x. @* y9 c. t# e
- if(x.length > 0){
( e/ D9 W) M9 t1 Q - for (i=0;i<x.length;i++){1 J8 j3 O- z2 k2 y+ ?0 H
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
0 {* l9 M1 G# F* T( m( v2 J6 G! o( Z - canonicalURL=x[i].href;
; T8 h# ]; c& ?' h- p - } @; @' N5 k9 R
- }
7 c, b+ @: L8 }+ W, `! F - }
7 \7 n7 ?: H& X8 _+ q) c% _ - //Get protocol
% b* |& T4 x. ]! _. c: o - if (!canonicalURL){: M' f8 l F' b* f9 b
- curProtocol = window.location.protocol.split(':')[0];
0 c' G5 `5 H# h& |6 D - }8 Q* S2 b6 a. M8 P, s7 V
- else{
! E# m5 k3 S* s# [4 Y3 X, s - curProtocol = canonicalURL.split(':')[0];
0 Q% q H2 J1 U, A - }2 h8 V) h; G% O. N0 ~
- //Get current URL if the canonical URL does not exist
[0 o, P9 ]+ w" T - if (!canonicalURL) canonicalURL = window.location.href;
8 Z) ~( f/ F6 Q9 y* m - //Assign script content. Replace current URL with the canonical URL
8 ^% q- Z3 u8 R% } - !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 w; A( y" q; [+ ]7 N
- </script>
+ y+ ^9 ?% I6 K: p9 n
复制代码
. Z6 ^9 J4 k" ^+ N2 k6 ?' y/ H4 E1 o L* c |* p; W; l6 {
1 g9 q f8 D. r
|
|