|
|
百度站长平台链接自动提交-js代码- <script>3 E2 r, o$ z7 F* ?! V
- (function(){
- P( i$ i0 r8 R+ v. u- `1 O - var canonicalURL, curProtocol;% @4 t9 [$ P6 ]! t$ M0 {
- //Get the <link> tag, t+ S' \+ ?, W& x3 l6 E4 u; Y5 }
- var x=document.getElementsByTagName("link");7 b( U2 D X: `0 w+ c
- //Find the last canonical URL
- U* [1 X. ?2 {3 b4 E - if(x.length > 0){- Z4 d5 o) I& t% E7 L
- for (i=0;i<x.length;i++){
% O F: g& } ^. C1 E5 e - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){, n, w% \; I* I% _8 h* o2 t# G* T
- canonicalURL=x[i].href;
3 y; u6 ^0 P, ] - } m9 V/ {9 [, G
- }
' B. h/ ]$ g0 {# w- l - } Q1 }) m4 c- L& T2 ^% M4 R6 d
- //Get protocol
W( y7 w# R; s - if (!canonicalURL){% m) P# L: Z' w3 q. i! [
- curProtocol = window.location.protocol.split(':')[0];
/ I% j9 w4 z0 N3 [! r6 R' `; A# b7 J - }( e4 A7 |0 v! g+ ^% U9 v
- else{
8 |' I: c: I# v9 R& O - curProtocol = canonicalURL.split(':')[0];
8 C! m& v. `$ ~1 |- ] - }- Z5 g( h- S7 _9 A
- //Get current URL if the canonical URL does not exist2 d6 G# H9 `8 q1 w# J/ R" u, e G0 w
- if (!canonicalURL) canonicalURL = window.location.href;
2 d8 [* e1 w3 J+ G5 x - //Assign script content. Replace current URL with the canonical URL# T7 n7 ?* v6 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);})();( y; C6 r4 n2 ]" f( t+ b
- </script>( @; N/ q/ x& D* [7 f5 X
复制代码
9 ~7 D; A2 j7 ^% P/ P0 L8 x8 w" ?; S0 i2 g) l& C4 G
8 F; V; d. h& a/ S5 W! s$ N
|
|