|
|
百度站长平台链接自动提交-js代码- <script>
% U8 N6 p1 m& @% W% i$ \ - (function(){
! l! l9 D* Q0 J |4 x - var canonicalURL, curProtocol;" [4 z$ V" ^1 N- E' C1 w
- //Get the <link> tag
# r4 g) o- l* b# C( v( F/ q$ w - var x=document.getElementsByTagName("link");
+ k7 C+ r7 |0 p/ L: l& [ - //Find the last canonical URL! s0 S* N6 Y6 t
- if(x.length > 0){
: v4 o! A- E* d/ M - for (i=0;i<x.length;i++){1 _" N2 ?& I7 w9 e) h1 ^
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
; r1 c( W7 O# O+ u# t* G - canonicalURL=x[i].href;- W! e; Q, q* ]. ^# K/ E' x6 c
- }1 ?# b$ s$ }/ U: m, g7 U' h
- }
; K" S6 C- u' N8 S5 W, @: A: F* Y! ] - }, ?& z& N+ W8 H. Y
- //Get protocol9 M; i( @1 g3 z& Q' m
- if (!canonicalURL){( l: E4 y- o9 g
- curProtocol = window.location.protocol.split(':')[0];2 ]0 o, v6 r: J5 p1 W
- }- ~) ^8 Q4 b V' {" ~
- else{
% }4 U# f$ V& O8 g4 j - curProtocol = canonicalURL.split(':')[0];* }$ [: _, l* u0 |5 E
- }$ C/ A4 a' y1 C" Q0 {- [
- //Get current URL if the canonical URL does not exist
% M) ]' s3 {( f0 X' v# i# \ - if (!canonicalURL) canonicalURL = window.location.href;. O5 d3 P: u1 y* {0 r
- //Assign script content. Replace current URL with the canonical URL
2 Z! z* w; e2 D [7 W# C+ E - !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);})();, S% F0 P* r9 g; O! e
- </script>
' M$ u9 N4 y- w5 }- D
复制代码
" m! c. \: z2 N; P7 U; {0 X
3 _1 ~6 [% O8 N! V! }. ]" r
6 ~9 E1 M. W; a2 M2 C9 J |
|