|
|
百度站长平台链接自动提交-js代码- <script>
! P: L$ o/ N- C+ d/ E4 h T+ D' {+ y - (function(){4 f; z" n* d) u
- var canonicalURL, curProtocol;
8 D- j7 C8 W8 e - //Get the <link> tag
# l. j4 S. l8 [/ q - var x=document.getElementsByTagName("link");4 R6 k% M! j& u. d! y2 Q* R j
- //Find the last canonical URL
( B* V9 E4 l- x9 o( [9 Y- S/ r' [3 _ - if(x.length > 0){
; z* D% h1 p; D, L - for (i=0;i<x.length;i++){
5 S- Q4 N7 o! Y4 P V" Y0 S - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){1 s- f9 F$ K2 Z, [
- canonicalURL=x[i].href;4 v# \- S/ j) T+ G$ H
- }/ h, ^4 I/ o: \0 B- [
- }5 V: E' m5 G- s; l: O& I
- }" j9 s% R# C* q: Y0 G" w% Q9 Y
- //Get protocol
# ^2 l& A# j+ g( P: ^+ `. p - if (!canonicalURL){, i, a! @: A. X, M' k
- curProtocol = window.location.protocol.split(':')[0];
' H B+ K3 G, \7 L/ { - }) b2 n0 y2 i$ v" z9 t. h
- else{ b. v6 h6 P2 b) m, W7 w1 m+ J
- curProtocol = canonicalURL.split(':')[0];+ k, d# E; Y& j& }. u8 c
- }. O& r+ `& z) R: _ R2 d
- //Get current URL if the canonical URL does not exist0 c' S; [$ E/ d$ x* J
- if (!canonicalURL) canonicalURL = window.location.href;0 K6 f$ i$ _6 U6 G5 K
- //Assign script content. Replace current URL with the canonical URL+ I1 k0 X$ }1 [$ s( h
- !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 y R$ R7 O+ b# n
- </script>
2 O. x5 j1 C/ i$ s c5 M! `
复制代码 5 y( C( ]8 y* y& N# ~. r
& A+ g9 B! ^2 U6 h5 q! c1 e; M
. _; c9 B3 d& [1 t0 c5 V( M
|
|