|
|
百度站长平台链接自动提交-js代码- <script>' A T! U l0 x2 J7 Z" W6 v
- (function(){0 o3 x4 v8 f; G* V" O% v% I
- var canonicalURL, curProtocol;. D; S& B2 t5 _, ]6 M9 `7 N$ X
- //Get the <link> tag
9 E3 p/ ~" D3 k0 h0 A' J - var x=document.getElementsByTagName("link");; d# N s* Q, u! S8 d8 L
- //Find the last canonical URL" K* N+ P( e$ B1 _0 x1 t7 k& E n# j3 `
- if(x.length > 0){: l- t7 X- ^! b' ~
- for (i=0;i<x.length;i++){
9 [: W4 L7 F" h+ _2 g" W+ B" w5 E. U - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
7 ]. j1 z' i" B+ V( U - canonicalURL=x[i].href;' }) }, ?* f9 _! q, g# @
- }4 v- y K& J W3 A
- }$ y, Y6 ^( t' P6 N# U( G- L
- }5 B- z! |! G( q9 P
- //Get protocol
$ C0 T- Q, @) a& i( B - if (!canonicalURL){
) Z6 Q# E6 f1 ~3 a3 R - curProtocol = window.location.protocol.split(':')[0];
5 ^* T8 V( D) g/ f - }
$ S& Q3 X& T+ C - else{% j/ c- S3 \. q$ {2 A
- curProtocol = canonicalURL.split(':')[0];1 a/ H" e4 J$ S+ h
- }# }7 g6 z! B- r& a5 r& Y
- //Get current URL if the canonical URL does not exist1 a0 T* [& h4 U8 W, O |
- if (!canonicalURL) canonicalURL = window.location.href;9 P1 O, Y4 [9 `' R- D9 E1 J
- //Assign script content. Replace current URL with the canonical URL6 s+ U c# b2 H$ s
- !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);})();
- u1 A+ p$ b, W/ |6 z; c D - </script>
! b( J- f: F/ Z& D3 m
复制代码
& a" `* f9 a5 `) i7 P8 V% Y# K
+ c1 P1 K3 \1 a) o- g' R0 e& P
. X( J3 p" ~8 V" i0 N3 r' i" _! g6 P7 } |
|