|
|
百度站长平台链接自动提交-js代码- <script># [0 q/ u. v1 y* T
- (function(){8 P2 E4 P. t- D D( _
- var canonicalURL, curProtocol;) K, U( t* ^+ s c& e
- //Get the <link> tag: V! ?1 A& a" F g/ w+ X+ a* F
- var x=document.getElementsByTagName("link");/ `; w* g% Q2 S
- //Find the last canonical URL+ C) j8 e: D0 J' P
- if(x.length > 0){1 D3 X0 X4 V G8 \ v: j
- for (i=0;i<x.length;i++){
) b) W$ p$ g' l/ m* _ - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){, t4 \% V c; F$ e6 M
- canonicalURL=x[i].href;5 F6 A3 H# g0 r& S* S2 o
- }! D- C4 T# |. [- s: G3 ^
- }3 d5 q- A- |, J5 \" l
- }
K- }% n( l. D& a& _! {, a - //Get protocol
" N k& o _" a3 v x - if (!canonicalURL){3 c$ A9 L" R. O$ j
- curProtocol = window.location.protocol.split(':')[0];0 ?# B2 M" K. p" U
- }
6 R! B1 j* v4 z9 H9 ? - else{
* D q4 }: I( \" ^ - curProtocol = canonicalURL.split(':')[0];9 _' a. f, G* p( P$ Q# b
- }
% _4 }- N8 E e& G# v. } s5 t+ D - //Get current URL if the canonical URL does not exist2 J4 |6 b) p5 a* R7 G& S* `
- if (!canonicalURL) canonicalURL = window.location.href;
, X* m" l& R [* m; X$ p - //Assign script content. Replace current URL with the canonical URL6 o2 u% L. S: g- f* N* J
- !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);})();8 j8 W* u0 W% p3 y& [/ S- S) ?
- </script>
5 _& Z* e1 _3 {' v( W! K
复制代码
* T( r% L' l* _5 R/ h& }1 Q+ P* o4 x+ z- p6 O% b. M: K
0 U* I, ^! b/ {" T
|
|