|
|
百度站长平台链接自动提交-js代码- <script>- Z% n( j5 E& Y$ s, c
- (function(){7 C+ U. h4 h' F X( C1 {
- var canonicalURL, curProtocol;# I' r* m3 u, p- q7 a# M9 Y
- //Get the <link> tag$ g- a/ S/ G& G2 Z
- var x=document.getElementsByTagName("link");
2 e+ V# l+ J* G' V - //Find the last canonical URL- r0 W6 q/ g8 _# s! K( p5 d
- if(x.length > 0){( K0 K2 B( [& `5 [
- for (i=0;i<x.length;i++){
' t0 H$ F( M L! T: T* N - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
% J& ?0 I/ [4 D) ~/ A( j, c0 y - canonicalURL=x[i].href;
$ [% A0 s7 G# m) i. v5 N/ I - }% V* f X1 k5 ^& ?
- }' R+ ^/ ~4 l7 c/ k6 J7 s; p
- }
0 E/ @4 d, z5 Y+ y5 n - //Get protocol
& }( [$ w; P5 M8 a6 E - if (!canonicalURL){
& a0 `% P* J4 d# A' _, O- S - curProtocol = window.location.protocol.split(':')[0];, K# u. W ^. W' o4 r8 p8 t
- }) t# y( o* C$ P6 f; i4 g. Q
- else{, l0 N& `" j( c4 B5 v
- curProtocol = canonicalURL.split(':')[0];1 r/ a" m4 |: h- ~/ ~$ R' k
- }
* P: o: w8 c2 g2 X - //Get current URL if the canonical URL does not exist
' T! K! [' \6 z! } - if (!canonicalURL) canonicalURL = window.location.href;
& R1 a P, f& |7 d3 I - //Assign script content. Replace current URL with the canonical URL
, m: f- r& s4 G0 b" v5 B4 \ - !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);})();' W; l) [& i3 {1 k
- </script>8 @' T, i1 b9 V7 C% u
复制代码 % n8 ^4 R/ o9 @ G* `9 T0 o) g' M+ U
2 K( A2 z2 u7 d2 X, b1 E
! K6 r0 G, U- t, ^7 Z& Z |
|