|
|
百度站长平台链接自动提交-js代码- <script>6 v6 w, F; h6 N6 D: t( @
- (function(){
' _4 c8 |8 _; R: ^- Y& w1 G% v0 A% E - var canonicalURL, curProtocol;
7 W2 J0 g, C! q! T - //Get the <link> tag; O* v6 r# T( j; f: n. n3 o
- var x=document.getElementsByTagName("link");
7 ~! L% P! W2 g - //Find the last canonical URL
# U! G) ?4 c' x' A) Q - if(x.length > 0){
5 @, c, x) b+ r+ a8 @& v B4 } - for (i=0;i<x.length;i++){
8 t4 ^$ u. y1 U7 C) b3 W - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
9 a3 _: ]1 k5 c( D& R - canonicalURL=x[i].href;% B o9 e! C" X/ B! t( ^
- }
- S9 F. Y! h0 x# p' R - }. j1 W |" e3 K7 L' f" P, H
- }) y3 i# b8 m g4 u" ]8 v
- //Get protocol9 s c' _. c1 ?; p" p
- if (!canonicalURL){6 L+ y3 x H% a- k' R8 H9 s
- curProtocol = window.location.protocol.split(':')[0];
8 \7 [/ H6 F$ c3 y2 b2 | - }
( z7 d$ }4 z5 D8 \( G - else{
/ A. ]2 f. f& c. U; ~ - curProtocol = canonicalURL.split(':')[0];, `8 b/ Q; H1 l& H
- }0 F) B8 P- J$ ?( v. w8 c* Q! l! m
- //Get current URL if the canonical URL does not exist" D0 H% v! Z1 l3 p, |: u
- if (!canonicalURL) canonicalURL = window.location.href;3 @2 W1 H6 X e! `+ {5 Y I
- //Assign script content. Replace current URL with the canonical URL: T5 e7 D% ^2 q) I, U6 R
- !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);})();) H6 S" J8 s" P ~9 g
- </script>
3 m3 V, Z& a7 A1 N$ I+ W/ q: c- n" D
复制代码
/ B; X- D) g+ Q- i4 g4 y2 d% ?6 U- x; s/ M+ g2 ^# |
+ X# `# D4 V0 x; J7 E+ u' }8 q' ] |
|