|
|
百度站长平台链接自动提交-js代码- <script>
) E9 r' g" Y+ o# ~ - (function(){ p7 m& f: a; Y8 H0 k! r
- var canonicalURL, curProtocol;
- j2 d" `9 u- T5 r2 l9 h/ X( @8 S - //Get the <link> tag5 j& e" B, ]: ?6 g% v
- var x=document.getElementsByTagName("link");) B2 P% _/ z7 B l! n$ B% M" h
- //Find the last canonical URL: R2 L, P' ?7 G q
- if(x.length > 0){" u& o9 ~; ~; O
- for (i=0;i<x.length;i++){3 D+ h- J9 H0 i$ z1 E
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
; W3 i0 x- \+ p& v7 u - canonicalURL=x[i].href;- S: @1 M; K; ]% @. n5 d/ T$ M
- }3 P* A- e& M8 I2 M4 R) S' Z' p
- }
( u. Y# Y! v2 L) l4 g - }0 i) q1 `4 y5 c5 b5 O) F% @1 s
- //Get protocol* q7 o Y7 d9 t$ l; A" c
- if (!canonicalURL){ }5 y) n7 \9 v% Y3 l5 Y6 m
- curProtocol = window.location.protocol.split(':')[0]; n* O Y1 f, B2 Q5 S
- }
( b1 j1 A" d1 T - else{
# k3 ^( U/ K3 M# A! ?* B& e' I2 h9 a - curProtocol = canonicalURL.split(':')[0];
. o3 k% \9 u% K: Y2 ?+ p2 d - } Y, ~2 }( L$ \ J% f- H$ `
- //Get current URL if the canonical URL does not exist
/ B% o- w. K* P/ \2 d - if (!canonicalURL) canonicalURL = window.location.href;
0 C* S( f5 u! r2 `7 j - //Assign script content. Replace current URL with the canonical URL6 O, p6 k( b E. j0 ]
- !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);})();& A5 b% y( [- P
- </script>
% D+ F6 d" t4 @& I) T
复制代码
, ~) l/ U# a+ }- [" u: n
- D4 A; F: Z v0 @% `- }1 N9 M
( u5 b. w A, |0 V |
|