|
|
百度站长平台链接自动提交-js代码- <script>
2 F: L4 Z2 [% Y2 _$ p1 x, Z9 }2 ^ - (function(){3 W7 R' ^: z, b' w- x, n! @
- var canonicalURL, curProtocol;
- I: X8 {8 E3 J4 C( ?% C - //Get the <link> tag
+ L. s. c( X+ X& n - var x=document.getElementsByTagName("link");, a$ d! \+ G# V) s" [; d. k& [# z
- //Find the last canonical URL
7 N+ }9 R+ T/ l" e - if(x.length > 0){0 ~; p0 ^7 z# e3 L/ o
- for (i=0;i<x.length;i++){
, g% N1 F( b3 @9 A8 c - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
1 I- J3 s `0 I) |" E8 c - canonicalURL=x[i].href;
4 |$ o% q4 n* p - }
, p, B$ _1 ^, { d. E9 E. L& N - }/ k+ @; y" {7 ^. V
- }" K+ l# w! ?7 ^' q
- //Get protocol
! M9 ~7 h% D9 P7 i - if (!canonicalURL){4 s* G% x0 V3 h6 w( n8 x, ]+ y1 p
- curProtocol = window.location.protocol.split(':')[0];
! r" t, U3 G. L, C! P; A S - }& ^* k. Z7 p; K+ J
- else{6 p! @. s% O! U( a/ k" J, r
- curProtocol = canonicalURL.split(':')[0];
7 V4 R* F K: ~( v" B6 i. O8 b - }3 N/ v. M+ M' W
- //Get current URL if the canonical URL does not exist6 F! {% K, W# F) w3 A5 x5 W; n0 g
- if (!canonicalURL) canonicalURL = window.location.href;
* }8 J% V4 w# [; ` - //Assign script content. Replace current URL with the canonical URL% @% `. k/ @% m; Y( 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);})();
9 K! q$ d+ V/ m1 z$ | - </script>
: s& b4 \ X5 Y0 K
复制代码
5 t3 a+ Z( J- A( G. j8 k# ~0 P9 W! V
8 V4 ^* q0 Q3 c- v- v
8 L3 X7 Q* P; I B: h |
|