|
|
百度站长平台链接自动提交-js代码- <script>* C; Q4 t( J; ?& D$ u6 e6 D
- (function(){
6 S" U$ y# a# |# `3 m9 K+ r; H - var canonicalURL, curProtocol;, M* ~' `/ H, F% h" L7 l
- //Get the <link> tag: K" i- {; x- R. k% I6 b/ N
- var x=document.getElementsByTagName("link");
. ]7 d+ k3 V+ f) y* c( D6 m - //Find the last canonical URL
$ y c* w3 a1 C2 E& q) ?; Y0 f& [. { - if(x.length > 0){+ m& d, d, J3 }8 D. j7 M% n2 r
- for (i=0;i<x.length;i++){
y& t \* L# [! i - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){3 K# W) a9 g: `. G, @% o
- canonicalURL=x[i].href;
7 h+ T( \/ |. x7 e6 T' x1 v - }
2 Z& y; U. C+ i6 u. Z - } E$ w3 p! ^2 `% v* u3 C. S) P
- }
8 F/ @! d2 \/ E4 }1 m5 i: a" G - //Get protocol
0 Z1 i7 [ n& a/ Y, E2 f" Y - if (!canonicalURL){
+ `1 O, f$ G1 b7 V& C - curProtocol = window.location.protocol.split(':')[0];7 Q* R7 p/ I6 L9 \
- }: S* [% Y6 x5 v- z/ [/ Y% J
- else{: e7 E% O% ?3 G( g# V
- curProtocol = canonicalURL.split(':')[0];% G8 E6 G5 z* ^1 N2 A
- }
2 u& c7 s( y6 z* a5 x - //Get current URL if the canonical URL does not exist: G3 w; R, V& h4 c$ V8 l/ H
- if (!canonicalURL) canonicalURL = window.location.href;
" _8 Y2 k( w- I! w [ - //Assign script content. Replace current URL with the canonical URL
7 y2 X+ ^9 X5 c% | - !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);})(); v: |7 |! L `! X7 Y6 I8 s
- </script>& y: k' u% e2 R- }* d
复制代码 % y7 X V3 R7 S3 z+ u/ {
1 `" B" u# O6 u/ K. w1 ?/ s
% ?( R0 n3 t' B) }1 \4 A: @7 b |
|