|
|
百度站长平台链接自动提交-js代码- <script>
5 R1 F( ~; x* E. s - (function(){; A0 }% R: `8 H- [$ C4 Q* T' J: O
- var canonicalURL, curProtocol;
. A, h& V0 k+ t - //Get the <link> tag
# g R$ R; M! }* {0 d - var x=document.getElementsByTagName("link");
* {5 M: a1 l# x0 a1 n - //Find the last canonical URL
, _. b- q& ]4 m8 s4 C2 f6 v - if(x.length > 0){3 j* m2 E- }1 C+ k3 u
- for (i=0;i<x.length;i++){% S4 {* v6 x9 t% @! d, f) l
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){5 u( x% s6 P R0 u5 c( A* S
- canonicalURL=x[i].href;: x+ C5 D' E' @# N L
- }/ O3 M8 o `( I! B
- }
! }7 s) e7 k4 F! p. D1 G ` - }& A+ s' ]4 g: O8 v/ ^1 ]1 d( L
- //Get protocol7 [0 B3 @% D3 ?4 f; E$ X
- if (!canonicalURL){
+ [, f9 ]# g2 c. M T. F - curProtocol = window.location.protocol.split(':')[0];" ^" s& V! E4 y
- }% |4 t0 |- F. |8 l5 E* |
- else{
* F \( R, Z+ @* R+ L [: p - curProtocol = canonicalURL.split(':')[0];+ F6 S v7 H E& x; t' U8 f: \
- }
2 D% p# W" b( m - //Get current URL if the canonical URL does not exist
- o i6 U, ~% l! h6 a9 w/ q: y3 ^: ] - if (!canonicalURL) canonicalURL = window.location.href;; C2 A5 n( v1 k. w0 k% }
- //Assign script content. Replace current URL with the canonical URL2 u! ?; @' p* w% }$ M$ _! w1 \6 }
- !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);})();, ~: x' T' h' n5 W) K
- </script>
% S, O2 j! q% e1 k& g
复制代码 / k) J: l2 \; p- {
5 v* F% E! k3 O9 D+ ^
, s x' r2 j* u |
|