|
百度站长平台链接自动提交-js代码- <script>
9 \- @% G% G% G3 B' k - (function(){
/ _+ M3 |4 u; R/ j - var canonicalURL, curProtocol;. Y3 Y, z2 T" D4 ]$ s
- //Get the <link> tag- j9 q3 U; V4 y; ?4 e0 S( m
- var x=document.getElementsByTagName("link");, j' e- W* P5 K# p: |
- //Find the last canonical URL. w: e/ U7 n e" |
- if(x.length > 0){$ U* ^! k7 z# e$ o @
- for (i=0;i<x.length;i++){
: d5 o. G z0 D0 i: T - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){5 w |2 Z, p# N J5 T
- canonicalURL=x[i].href;4 A' H) Q" `( y( ?
- }
* Z3 ~* p6 x0 \+ M3 j9 C/ ^ - }
- t& }/ G9 u3 v6 ]( b# W7 q/ [ - }4 @) g" l& R/ T' a& u) J/ J6 v
- //Get protocol
9 w2 W6 p! j5 N& W6 o+ h - if (!canonicalURL){
$ [6 Q: M* }0 h' V6 v. I& o$ i e7 V) G - curProtocol = window.location.protocol.split(':')[0];% M5 G: h+ h' P! S
- }
; Q9 U" R* o! U; r5 }4 c! M0 \ - else{" U. p& W3 T4 o4 V( K
- curProtocol = canonicalURL.split(':')[0];
0 ?1 ]: T. q( t+ y - }
& ~4 Q( l( J7 W' O+ R1 c0 _ - //Get current URL if the canonical URL does not exist
; o$ P* Q# M, n5 ?+ k% _ - if (!canonicalURL) canonicalURL = window.location.href;: n% P6 v2 Z5 S$ `* v
- //Assign script content. Replace current URL with the canonical URL" v/ ~! ?& j* _0 L
- !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);})();
) ?- ~" Y! q* e* `1 _- r5 Y3 x - </script>
" J" I; w; e8 Z) C0 {9 q0 L" x7 g# E
复制代码
( z$ e' N Q" b& Z2 P+ W2 r' r" f/ }# v% u* Z/ v
5 H: m* s8 [4 {: ? |
|