|
|
百度站长平台链接自动提交-js代码- <script>
) @9 \& d& D% F" e: h- v( X# Z5 f - (function(){
+ d, H, ~( ]8 u - var canonicalURL, curProtocol;
. k- E/ W$ K$ Q% T9 o( X - //Get the <link> tag
0 l3 d6 K* _( ]3 t5 }; a, p - var x=document.getElementsByTagName("link");
0 P8 k$ a+ S3 ^5 b2 h: \( y - //Find the last canonical URL4 J% d$ h1 B& U/ A1 T% y) L
- if(x.length > 0){- z$ H! i* X* [2 w
- for (i=0;i<x.length;i++){
! O9 r. V, M' y1 T5 J! c. q - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){2 c0 }! T. q; f
- canonicalURL=x[i].href;
b/ h+ R/ I4 m8 R4 _' L" r - }
b7 c7 z4 q; x( A6 @ - }
# p; y$ R! Q5 V, K - }
4 H3 p6 p! O# o0 y9 q" w" Z1 e2 h - //Get protocol
$ b8 N7 G1 D, k/ q1 _) s3 f: s' H - if (!canonicalURL){
4 w7 @+ @! m( |# p0 }& M4 e7 b% ~: A# H - curProtocol = window.location.protocol.split(':')[0];6 m* n; `4 p4 A" q6 C
- }
- z2 H$ X k* j/ T - else{
- N P/ c1 y4 X$ o: z( _' {) t& x - curProtocol = canonicalURL.split(':')[0];
4 ~! {- i( n9 f# ^% v. ^ - }
: J' b4 X9 B+ a6 Z - //Get current URL if the canonical URL does not exist
9 Q: Q* z$ S7 q- [/ F3 @ - if (!canonicalURL) canonicalURL = window.location.href;
. Q% U) `" ]) c! w - //Assign script content. Replace current URL with the canonical URL$ u c7 C4 i9 }; d9 w: O, o( p! 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);})();
' w% ^- W& L: g# { - </script>
5 a( T2 [& d! Y! C+ U+ w- M
复制代码
- `& X1 P! ?' a
0 V. J3 D4 b! c9 t( ^/ a" `- w/ Y8 \: C
|
|