|
|
百度站长平台链接自动提交-js代码- <script>* z1 c& i( V$ F4 a# d
- (function(){( S+ M+ G* N4 N6 Y$ j
- var canonicalURL, curProtocol;( s% @7 a: p% q3 ?
- //Get the <link> tag8 r% M* j+ ]9 X1 o# O+ P! @8 f+ @
- var x=document.getElementsByTagName("link");
, x( w4 Y5 N$ B, y - //Find the last canonical URL$ w$ F& S% i3 r9 O8 D
- if(x.length > 0){
* M. G/ ` }! D9 Q# T - for (i=0;i<x.length;i++){4 ? L z& Y) q3 d U+ N o4 ?
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){3 H; `" Q! o$ e& }. O3 r/ q% i
- canonicalURL=x[i].href;
( u) R5 [+ D% M5 }: V! O) S - }
; K/ t/ j4 r5 V D - }
& ?2 L1 o9 k/ P. P& g7 J - }
4 X. O% j: u! y/ { - //Get protocol
7 t8 B- }& h+ U! a3 W - if (!canonicalURL){% t; M) s2 Z) q* C6 _
- curProtocol = window.location.protocol.split(':')[0];
# P% J7 i1 @1 U- ~9 e8 G; f) Z - }
. g) S+ W0 k- t% W3 g% b+ j0 J$ w - else{1 m) z; y$ k ?
- curProtocol = canonicalURL.split(':')[0];
' R* T) Q7 s/ m! W) O" [ - }) m, `" }( o* u2 e+ [5 K/ J
- //Get current URL if the canonical URL does not exist+ I4 l# \3 Q2 M/ ^: B# I
- if (!canonicalURL) canonicalURL = window.location.href;7 p/ `4 H4 R/ H
- //Assign script content. Replace current URL with the canonical URL
& {: S7 m- f! j9 W- c R1 |. j2 a/ o - !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);})();0 W( Z% Y, }/ D( o
- </script>
& R& ]. G9 W2 a. v) N
复制代码
" n' C3 j' M' [
* }1 Z3 G& ~7 o' f
1 J. T: G, B4 O, g* c |
|