|
|
百度站长平台链接自动提交-js代码- <script>. c- H% i# z0 t$ O4 S
- (function(){" {1 G( R/ ~/ U, j$ I+ `0 G# f1 m
- var canonicalURL, curProtocol; q e, k( e4 h4 O+ Z
- //Get the <link> tag
' x' o4 O# U& n6 ~* ^9 c - var x=document.getElementsByTagName("link");
5 b5 R3 |& P: {+ J @ - //Find the last canonical URL8 q% V' F( t/ M/ e# J
- if(x.length > 0){' S+ l' J D7 f0 Y
- for (i=0;i<x.length;i++){
r7 [8 L, h7 H9 K! O - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
4 t& }" q& f- j' x - canonicalURL=x[i].href;
/ K' j' E- F( N/ X0 Q/ |6 ^ - }* K* E0 l( C) Y
- }
6 `$ V: Z+ y; R4 `' d - }) J5 n3 l1 o/ d& [. i
- //Get protocol, W z7 \5 j& {: U( }) T
- if (!canonicalURL){1 w5 J( ^' x& I! G( E* S: D
- curProtocol = window.location.protocol.split(':')[0];: ^. H0 V. J0 C$ h+ k$ i
- }. ?8 _0 ? |! d$ ]0 c9 j2 K
- else{
~3 p* M/ M0 G, r e2 v7 |( |, l! ` - curProtocol = canonicalURL.split(':')[0];* {5 s" s% m$ C P# L4 T
- }
0 L$ ]% o% }( p - //Get current URL if the canonical URL does not exist
% F5 {/ H! |4 P - if (!canonicalURL) canonicalURL = window.location.href;0 i# r8 T$ ]- T) x% W, i
- //Assign script content. Replace current URL with the canonical URL
- W9 y3 ~) o# N0 z2 D8 t' o+ J, r3 O - !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);})();% g7 T! R: K% r* F
- </script>6 Q% F, Y" A5 V9 Z( v- _
复制代码
% P, O; f' z! e. f4 A4 q0 @: l. I) l% D/ m# D' p$ N1 b% T
9 C% w% y/ P: F. H2 u8 [ |
|