|
|
百度站长平台链接自动提交-js代码- <script>, G, n* H2 F* v5 {9 x0 i# q
- (function(){9 g0 v( p: l5 \* T" [, z
- var canonicalURL, curProtocol;
& e D/ s. t; F1 v. r3 k - //Get the <link> tag8 U* E# v6 a' k( Q% J
- var x=document.getElementsByTagName("link");, \- V- l$ ^9 J
- //Find the last canonical URL5 n) B" K( [0 l4 C% [ u, P& ~
- if(x.length > 0){
" Y) k! S1 G+ _! b) M* M - for (i=0;i<x.length;i++){
- p+ K4 J4 @4 I! G4 I - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
- q7 b( y3 @& _& O7 E - canonicalURL=x[i].href;
6 I8 w' w) ?- ~0 m, Y - }& p& T! Y! \8 j; ]1 I
- }. U3 s6 y. }& @2 F a" K1 u# T
- }
0 v! \4 G2 B9 |3 E5 R2 _% e7 c' } - //Get protocol
: L' i. t* r: L& D8 x e9 y7 v - if (!canonicalURL){3 c. x2 O, L% L# @$ U" K
- curProtocol = window.location.protocol.split(':')[0];
2 ~6 v6 z6 {! @ j2 }( u7 A - }
7 C) e% S% t) f7 {0 r& f% N1 b - else{
# E9 y2 c" ]( g# G( E" d+ o8 _ - curProtocol = canonicalURL.split(':')[0];
' F) e4 Q; s! F& e" b4 m' k4 e" f* L - }1 R; t' F# ]" y& c6 F2 K
- //Get current URL if the canonical URL does not exist" n3 z1 d9 }/ U) F
- if (!canonicalURL) canonicalURL = window.location.href;
( ~% u- ~/ Z, o# }$ m - //Assign script content. Replace current URL with the canonical URL2 e' X$ b0 v5 ]: S+ b9 e M, [
- !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);})();
! k, p5 |0 k4 `5 B, F - </script>
* u) X& u( R" W0 s) ^
复制代码 . v+ O( \9 c* b9 z3 }
; \& ^/ q. j( ~
9 i6 s) l1 Z2 }# i |
|