|
|
百度站长平台链接自动提交-js代码- <script>6 F0 q+ q: ~& ]5 a" N
- (function(){& A# Y J3 @3 v7 j# g/ |: I
- var canonicalURL, curProtocol;; L+ A9 y5 e, y
- //Get the <link> tag$ z0 T2 N2 F2 e2 ?% }
- var x=document.getElementsByTagName("link");
( |+ [9 T& r9 H; ~! A1 i( _ - //Find the last canonical URL
/ Q: t! l0 ^- E - if(x.length > 0){
+ V. l/ c8 L# b6 Y$ P' F, r - for (i=0;i<x.length;i++){7 ~# A0 Y; B) f. s3 M, Z& ^
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
\+ _! L0 _& n& I0 ]+ R" V; @ - canonicalURL=x[i].href;; {8 r) l* e7 T
- }; ^3 ^3 T* G2 U) {; J$ P Z# l8 F) Z
- }
7 {* q. X' _! H/ o+ W$ G - }
& ~$ o K7 B( s; F$ j - //Get protocol: L; H& q6 m; e6 Y( b# P9 [
- if (!canonicalURL){3 v3 K. D$ y" I
- curProtocol = window.location.protocol.split(':')[0]; z( z( b; B* H0 r( c7 z4 c& t
- }4 k T; T+ U- Y8 [- t1 p6 e
- else{
4 w! a J; K' F V - curProtocol = canonicalURL.split(':')[0];5 L+ ?; Z+ X3 D
- }: w- a) l M3 `8 _2 x0 \: p
- //Get current URL if the canonical URL does not exist
7 T: R& G. D0 L - if (!canonicalURL) canonicalURL = window.location.href;
% z/ x& F4 B. k5 J% [+ m - //Assign script content. Replace current URL with the canonical URL. \4 V* i8 I, }3 K
- !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 a* F5 @5 P9 M5 P# Z - </script>
; q; P. R4 e/ I: K3 U8 B/ N4 B0 h
复制代码 ! _) }% o: Z$ d4 Q- _0 V0 a
# q% D* j8 Q8 ]1 @3 R1 ^! T' X$ f- c- w
|
|