|
百度站长平台链接自动提交-js代码- <script>0 l1 i9 W( p S0 ~, Q
- (function(){
i1 f! U; Q3 V - var canonicalURL, curProtocol;
% L% p( C, T0 c, l# W6 C - //Get the <link> tag& K* p8 \. v/ ]
- var x=document.getElementsByTagName("link");
3 @1 Z% Z6 ?( R4 B, Y - //Find the last canonical URL0 w! W4 q2 W! d) M0 E4 Q p
- if(x.length > 0){
/ f; r9 I' Q& H' i - for (i=0;i<x.length;i++){
6 o! Q0 h7 n: K. Q9 |8 @' _1 B - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
' d6 Q& A& I( C1 @) L5 j% @6 u - canonicalURL=x[i].href;
; _% ]& q) t% p6 x - }
3 i, B! W& S0 y9 o6 C6 u - }
% _; n `; i% r3 V - }% P4 w2 _' H$ A( `+ [; ]: s2 M
- //Get protocol0 H" E; T1 Z) D# C
- if (!canonicalURL){. L" B7 J0 o$ @5 C( l- ^6 F
- curProtocol = window.location.protocol.split(':')[0];
5 f8 U( `- R2 Z0 w! g0 d - }, V4 Y+ o% P) [
- else{% U. I+ P4 O( G& U- k
- curProtocol = canonicalURL.split(':')[0];2 v8 g0 Z2 ~7 R6 E9 n$ t
- }6 p: a0 Z* J8 p$ }5 F! W
- //Get current URL if the canonical URL does not exist
# J7 [9 [* T8 q1 K% @" L - if (!canonicalURL) canonicalURL = window.location.href;8 I4 V8 E3 H/ P, m: A( X$ Z
- //Assign script content. Replace current URL with the canonical URL
, e* \* l- j6 ^0 L/ P3 C - !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);})();
8 {0 x5 w5 t$ ~( i* x( c - </script>
, k! L2 Z9 S6 U1 g1 x5 G+ ? e4 }# x
复制代码
- r" u2 X1 B8 l
% Y0 M( q* |0 E3 T: O
& @% y4 i1 Y( C6 T1 P! P |
|