|
|
百度站长平台链接自动提交-js代码- <script>: {4 Y2 q f, }' L
- (function(){5 c. c3 h( [! a8 d" s3 P
- var canonicalURL, curProtocol;
9 Q1 c. K; E9 h, V( a4 L9 ^ - //Get the <link> tag
; G# `8 h( S1 C5 E8 y$ ]# r3 f0 [ x - var x=document.getElementsByTagName("link");
5 |' g. H, Q+ p+ _6 R - //Find the last canonical URL
5 E* A G) x% h* u - if(x.length > 0){/ ]: ~+ Z. `/ H8 n
- for (i=0;i<x.length;i++){
3 F# S! l5 P& W$ I - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){+ v" D" k% Z+ f
- canonicalURL=x[i].href;
; j {8 ~- E* G% ~8 B/ C - }
0 ]; s! u+ O- k; [ - }
$ h% C* D* A' |* v5 ?% M - }. O, e# U9 Q* u1 R$ m2 r
- //Get protocol
1 w+ w8 v3 h) E" s e m1 { - if (!canonicalURL){+ b* I5 @4 Z& f% ]
- curProtocol = window.location.protocol.split(':')[0];; M. g8 t, T9 } n" c
- }5 Q/ U. h0 F9 E( l- T' w5 }, ~% W
- else{9 N, b, k+ e, `5 U6 k/ H& s
- curProtocol = canonicalURL.split(':')[0];
9 o* L8 L+ k9 O1 P - }( g3 |% T6 Y. {5 n5 c- ^
- //Get current URL if the canonical URL does not exist. N; h ^, S( ~) a
- if (!canonicalURL) canonicalURL = window.location.href;2 B. N5 U1 r+ }6 E B9 c. H+ p
- //Assign script content. Replace current URL with the canonical URL ?4 G b! r7 u$ J# x3 Y/ d T
- !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);})();$ x8 Z( g! G) e: u) A
- </script>1 w/ A5 G# o, y
复制代码 7 A# j" w8 \1 j7 U' b
0 D4 S4 r4 N4 i3 b# `% n7 K# ?$ e. Y8 E1 v
|
|