|
|
百度站长平台链接自动提交-js代码- <script>
! U$ R# o4 G8 [3 N - (function(){
( D! x: ]9 q& V: F& m0 j - var canonicalURL, curProtocol;
( a6 X: y3 f1 M8 X - //Get the <link> tag# [6 F( `% g" y! c' j. [2 U+ E
- var x=document.getElementsByTagName("link");% k e2 C! W# i3 _* Q3 d) I
- //Find the last canonical URL
- }2 Y" N# m% S: B( m$ G - if(x.length > 0){5 O2 ^1 U4 [" y- h
- for (i=0;i<x.length;i++){/ }; M& _ I F3 }/ g/ E; f0 d
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
0 J( w) Z' c2 L! E - canonicalURL=x[i].href;
m- f! J2 [! H' b9 K. a0 a - }
' {7 j7 j0 a) T! N1 G0 p3 f' Z Q - }
f: O4 ~" O7 w/ r% p - }
9 t. V- t% k$ F5 l, T - //Get protocol3 Q6 K2 O" Z2 _# W! W- u
- if (!canonicalURL){
4 `) S0 _. C3 P& s$ M3 h. d - curProtocol = window.location.protocol.split(':')[0];
4 a! T0 U6 k4 G1 R$ M' s - }
" Q4 a! s7 U% d3 a* g6 d$ j - else{ U( M- f% M3 R2 W
- curProtocol = canonicalURL.split(':')[0];
$ w2 A3 e/ j" Y# z# F1 ?: B - }: R3 i6 Z$ M8 m; X8 q
- //Get current URL if the canonical URL does not exist) Y% g3 U0 m1 p" e' C2 a/ K. |2 h
- if (!canonicalURL) canonicalURL = window.location.href;+ V @ j- A7 B5 G/ Y
- //Assign script content. Replace current URL with the canonical URL6 ?3 d' Z; B% Q1 n4 q% D
- !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);})();
6 k# p u+ M! C4 u# g9 C - </script>
/ T9 p0 [" T4 r ?! n0 `
复制代码 7 { `) v; V. Y9 Z
$ L. e$ d" h& d- O8 f: r) m/ `# w
' j, A9 r, @ Z$ x
|
|