|
|
百度站长平台链接自动提交-js代码- <script>2 B: r9 S& n7 f Y; X
- (function(){( c" p2 R3 z8 f3 f. v) n# |/ I
- var canonicalURL, curProtocol;
4 K2 a1 i7 J) ^& P! q - //Get the <link> tag/ A( { e" i! ? X+ G, \2 O
- var x=document.getElementsByTagName("link");' m4 O- d( |" \0 D
- //Find the last canonical URL0 E5 n& ~6 l: ~
- if(x.length > 0){( ]1 V r$ e% R! I$ p- ^
- for (i=0;i<x.length;i++){: _/ \5 I/ i9 j6 O4 a/ \4 E3 F
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
, b6 _& Z0 r% i; W4 L- m) t3 l - canonicalURL=x[i].href;' k& w/ B& ^. |5 a% z0 m$ J* e
- }# ]" ` H0 y0 N$ y( d
- }! n0 a5 G. S" G
- }& @5 S* Z& \* H. [1 [
- //Get protocol
6 l9 O3 A6 o( Q - if (!canonicalURL){" @3 G% E# I$ n: F2 L
- curProtocol = window.location.protocol.split(':')[0];
7 y2 `: N& C: I6 ?: X& | - }, S( i g3 R( |, n
- else{
$ e+ d7 \+ `% _# l. ^ - curProtocol = canonicalURL.split(':')[0];7 S2 F4 n% i- ?" `% S
- }
0 f! Y5 @& g- ^, j' {& [0 k - //Get current URL if the canonical URL does not exist
8 T. k. {; C! M d+ N& L - if (!canonicalURL) canonicalURL = window.location.href;
# N7 ?4 v& N1 X2 u. b8 m - //Assign script content. Replace current URL with the canonical URL& I2 m% [2 x! ~5 b/ K
- !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);})();! W3 y) D$ t# E
- </script>
* g6 q) m/ K! T2 T
复制代码 ) G/ D! m* W* L) k+ ]
; j; M3 n1 j7 p9 M
2 r. I' m6 m% J) t |
|