|
|
百度站长平台链接自动提交-js代码- <script>! y' ]6 y% U# @5 N) a
- (function(){
6 z( d/ I- J3 U1 I! O$ U - var canonicalURL, curProtocol;* K( c- n m! P% I
- //Get the <link> tag
# \* N. n" y9 t* I - var x=document.getElementsByTagName("link");
2 K F3 H' i5 P& B - //Find the last canonical URL. s# ?* w; d+ V% s" e: V
- if(x.length > 0){8 U# \ T" `! F9 E
- for (i=0;i<x.length;i++){
) g) j4 ]; R- n7 \6 G, w$ d - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
1 \& H. [0 u" c6 `+ S8 O* o% | - canonicalURL=x[i].href;; \2 f& Z+ f& f/ ?
- } Y2 n7 o! y* D4 v" x m! ?
- }# b4 P( U9 p# A
- }& K2 A. N) \# c4 c' j
- //Get protocol# ]8 A! p7 m+ _
- if (!canonicalURL){" p) W9 P' Z. O! A
- curProtocol = window.location.protocol.split(':')[0];% ~ T0 z% h' r9 ^3 N& {% G
- }$ j; V; l) f) Q/ f+ Y5 [* d
- else{ W: U) U# L. b, B U
- curProtocol = canonicalURL.split(':')[0];
6 D W1 ~. b% ]" N" a. U - }0 h. f7 [0 [" z- S. u, t* M; C- \9 _$ ]
- //Get current URL if the canonical URL does not exist
! E* q5 p! A9 `9 b7 J& G" ~ - if (!canonicalURL) canonicalURL = window.location.href;
) i; j; I+ b+ V; w - //Assign script content. Replace current URL with the canonical URL# n0 F! ^$ s; 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);})();+ E0 t0 n% K7 Q! f& {( J
- </script>
3 E9 M" F: ^8 ]+ V2 E# q0 f
复制代码 % Z C. ?! G4 Z7 G: E- H- W
$ L4 G/ @( Y9 k/ |* `
3 t# ^; j9 i' ~+ i
|
|