|
百度站长平台链接自动提交-js代码- <script>- Z8 M0 ]; I' K, d; ~
- (function(){
3 D* P9 a, F$ t# u: q - var canonicalURL, curProtocol;
! X0 X( T# ~7 I2 o* n6 n* w# R" ]/ W# E - //Get the <link> tag+ h. Q) M0 A! Q( }' T: ~6 j/ n
- var x=document.getElementsByTagName("link");8 s4 K/ I3 S) e9 z7 ^% v7 [# J
- //Find the last canonical URL
, P1 u7 C- o V - if(x.length > 0){
2 S3 W% H8 ^, o/ g% } - for (i=0;i<x.length;i++){
8 q) `' [2 W: i" H3 P - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){/ V) `4 S/ q% V7 I2 ]1 x. Y
- canonicalURL=x[i].href;
4 B4 X1 t1 ~# A - }- q# a7 F. u) {, N7 V4 o
- }
' t, H& \7 o( P1 Q - }( M: t+ K: a5 H* B; Q3 m* g
- //Get protocol
4 z+ n. e2 D7 o# Q - if (!canonicalURL){
; Z T. B8 W3 [1 z6 [8 E5 Q - curProtocol = window.location.protocol.split(':')[0];
' \3 F6 D/ s) L/ h7 _8 X! ^, M. y8 C% r - }
$ D5 F2 T0 B# F1 T9 x) N- m - else{
7 {$ V- ]! C; v9 V n, K - curProtocol = canonicalURL.split(':')[0];
f0 ^4 o$ u& ?% p' t" A" O - }
3 P0 u' d3 b" j+ V1 p - //Get current URL if the canonical URL does not exist# H, z+ U- ?% N3 H
- if (!canonicalURL) canonicalURL = window.location.href;+ z. H$ z8 s ~( k# E
- //Assign script content. Replace current URL with the canonical URL
! w( N N' ^1 h* i$ _ S# `0 s - !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);})();5 {: }' |" W1 m" |; t0 H( y
- </script>
" Y$ j$ j1 V0 |% `) n; k- O
复制代码 8 r0 T" y2 w7 o0 o8 S6 `
' A [, f6 ^5 s
5 P; O: ~6 E6 y1 C- e0 }" `, s |
|