|
|
百度站长平台链接自动提交-js代码- <script>1 X) Z, L( _( U( M7 m( z& o
- (function(){
1 }" J/ d$ B4 o7 m, M' x3 b - var canonicalURL, curProtocol;
7 q! y2 `+ {$ ? - //Get the <link> tag
1 O6 j8 N3 u; z3 P' g e* ~ - var x=document.getElementsByTagName("link");
8 ?, D. ]" ]" H9 \5 m% X2 H - //Find the last canonical URL: [4 y- H- G- O
- if(x.length > 0){# H& ?2 P6 P7 t2 d, q' j' [+ s
- for (i=0;i<x.length;i++){3 \) Q7 O5 Q5 `" {
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
1 g, G8 n; Q. {+ ^% c - canonicalURL=x[i].href;5 z" z2 u, @& p' {/ t) w, {
- }& G# k! k2 w* H: |( o$ o' g8 n
- }* }$ U. U" n8 I" q/ u
- }
1 ? L$ P% v3 `2 K* {; o* e - //Get protocol
4 y! q7 v6 P0 ]7 x: a7 d - if (!canonicalURL){8 l2 T% a+ f" U) @+ p
- curProtocol = window.location.protocol.split(':')[0];
% W8 X' p4 S% ~' d8 N+ l0 r9 p - }2 c3 M7 w/ m1 |# x) {
- else{, N, m. o1 S; O8 k$ r
- curProtocol = canonicalURL.split(':')[0];
0 ^: I, W% g% \* p& t - }: u* w8 B, N7 w2 ?- v& z
- //Get current URL if the canonical URL does not exist
, K) g, |# ?. j5 Y3 ` - if (!canonicalURL) canonicalURL = window.location.href;
! @* B% k) X- W7 _ - //Assign script content. Replace current URL with the canonical URL
! f% T4 S. D5 b& j) x - !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 D" k! L5 ?+ n
- </script>0 w& s/ Q2 F9 K8 T7 y$ O7 F. d( Z
复制代码
" b: w, g5 r% V1 R4 J& v! |4 P' e h9 i/ Q+ G1 O0 c9 A# d
1 ]% [' a7 q3 y! v. x( G. T, C
|
|