|
百度站长平台链接自动提交-js代码- <script>/ B$ P. U0 U$ s1 F; W% `( A* T
- (function(){5 c8 D( [7 x# S5 {
- var canonicalURL, curProtocol;
9 q: S/ }7 g- M+ j4 T - //Get the <link> tag
9 D0 Y6 G- R+ q; U+ u7 y+ } - var x=document.getElementsByTagName("link");7 h$ w! Q& Y# |( N! K3 ^, O, {
- //Find the last canonical URL
0 x2 `" M3 C2 N - if(x.length > 0){$ `3 X, W7 F- k$ H7 e9 ] N
- for (i=0;i<x.length;i++){
7 @& ^, {. S: y7 A8 j7 R - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){' P; F$ ]6 x- v1 N$ K& z- c# s
- canonicalURL=x[i].href;& u; L$ W0 _/ N% Q
- }6 C0 ?- d5 D/ c1 c& B
- }5 H+ _, Y5 F0 \" p5 U: H
- }
/ \5 [" f" q% F - //Get protocol" N& e8 P! \8 v
- if (!canonicalURL){! J. D8 P" d0 n! M" F* U
- curProtocol = window.location.protocol.split(':')[0];
- p9 F* a9 {7 R1 X; s% e - }
# ~. j/ p* k5 _) P& h - else{
& L, y# M, P$ V* l - curProtocol = canonicalURL.split(':')[0];# e& \: F: }& D0 M$ J
- }2 m X9 J2 B( |4 I
- //Get current URL if the canonical URL does not exist
8 O. l1 C M5 w5 N6 ]: } - if (!canonicalURL) canonicalURL = window.location.href;
# s' x- f% e( v) | - //Assign script content. Replace current URL with the canonical URL
/ J' R4 D, t4 u0 ~, R" G S - !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);})();
) I3 F0 M; @; K5 `' W- } - </script>
* c2 [3 O3 V, o/ x* l
复制代码 8 A& K T1 r: }& m& N6 j4 N3 W
9 {; u+ Q& Q9 G& Z4 F3 L% f9 e. G( D, a1 R. Q8 v- }( M
|
|