|
|
百度站长平台链接自动提交-js代码- <script>9 ?2 g$ ^$ K) q; t3 m7 E
- (function(){& r3 C" T) H# U1 B+ E& |( a
- var canonicalURL, curProtocol;; ^# x! O: Y' A3 c1 D8 ~- ]; G
- //Get the <link> tag
7 _5 o8 Z* V+ d! _. \ - var x=document.getElementsByTagName("link");3 { m1 T z2 A( L& P
- //Find the last canonical URL
- s2 O" r# K3 K) B& T0 B - if(x.length > 0){
3 z/ t: f* [: T - for (i=0;i<x.length;i++){% Z! t) h1 |8 G& a3 ?2 K
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
4 C$ ] x# k1 P& c9 q - canonicalURL=x[i].href;1 T: M x; v( E3 I3 W2 B
- }- _6 w4 \7 x! t' a3 X, Z
- }
; e" a1 X- U0 J; n - }
0 V* |) w0 H; P, w) F8 t0 D3 B - //Get protocol
) o- \! d9 t8 X - if (!canonicalURL){
r) O$ L; ~! a - curProtocol = window.location.protocol.split(':')[0];
4 N# f6 Q0 S$ J - }
, N6 F: j/ {4 A/ p' E9 P - else{' |* a. Z! D+ m
- curProtocol = canonicalURL.split(':')[0];
@* R" {2 n* n0 z: N - } D, I6 F4 |( i4 G! \3 Y
- //Get current URL if the canonical URL does not exist
$ [; m C/ w2 s) M. u+ O - if (!canonicalURL) canonicalURL = window.location.href;
5 {4 p! r# g% A- S8 o8 G: ^ - //Assign script content. Replace current URL with the canonical URL5 a7 c, [" K+ `8 {. a$ J& E' @
- !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 f' e z: j0 G3 M% } - </script>1 H7 _& M9 u$ {; T
复制代码
; k2 L8 `/ D* ~/ L2 k( W
* @# i0 X3 b6 K' g7 |' m" N* [. u! ^1 v0 Z
|
|