|
|
百度站长平台链接自动提交-js代码- <script>6 z1 Z1 o, f" X; D
- (function(){4 v2 p }4 s8 o( v5 W# Z4 s& i- f
- var canonicalURL, curProtocol;
+ q) ^- p" v1 l- Z) d9 |! C - //Get the <link> tag
. w! K' d+ b ~ - var x=document.getElementsByTagName("link");
( e1 f. d! l# e2 \4 h - //Find the last canonical URL5 D& U4 N4 C3 V e+ o) ^; W" k
- if(x.length > 0){, j# r5 G: r! b: }/ `, o7 D0 P+ ~; Z
- for (i=0;i<x.length;i++){
: F* y/ p6 O4 F - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
) a1 D+ F1 d9 w9 n) B: H6 r' P5 Y - canonicalURL=x[i].href;
2 ]# B/ c% a( ], `* z$ Q7 r z - }
% e% z' b+ V7 p - }
% H" w# O% v3 `& W* d4 e - }
0 d) M8 @! Y' f! o( k1 Y2 n1 ?' @3 q - //Get protocol% Q f4 T8 W+ y# B
- if (!canonicalURL){# K+ {* h$ c, d1 D5 C; Y7 Q
- curProtocol = window.location.protocol.split(':')[0];
2 A: c9 @ G( c# y8 u* ~: w* \ - }- n& Y4 B! W) d" P, E, @6 l6 N H
- else{3 p5 p7 `' J0 r
- curProtocol = canonicalURL.split(':')[0];/ B( x% ~: p* ?4 H3 Z
- }
( K' Q8 g2 L- e/ a - //Get current URL if the canonical URL does not exist3 k/ |: K o- V/ R- Z+ t1 y
- if (!canonicalURL) canonicalURL = window.location.href;
5 |$ a) r! T, @ - //Assign script content. Replace current URL with the canonical URL
3 a |, V$ |! q% } - !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);})();
% J4 p/ R4 P8 P9 y - </script>& U9 a0 o: A0 K* I, J
复制代码
% V3 K. T: @# Y$ _( H! n. F$ L
7 u8 n% \' U: S; h5 m+ |6 P7 k3 @! s
|
|