|
|
百度站长平台链接自动提交-js代码- <script>+ c) e9 G" q% M
- (function(){
7 Q6 t$ H! k/ i. u) \ - var canonicalURL, curProtocol;7 n |/ X! S. F6 ?
- //Get the <link> tag1 |. ^+ K( e1 A6 }% M# X
- var x=document.getElementsByTagName("link");
3 }6 s! k" M% l" l& | - //Find the last canonical URL
5 x' q& H% w( Q4 F# ^/ G9 U! J - if(x.length > 0){
: s' S" x; @# t - for (i=0;i<x.length;i++){
" {9 g) B- ^/ ?" y4 s8 Y% K1 D - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
! G8 O) Q$ B6 _: v7 U - canonicalURL=x[i].href; o7 q% w, c, J/ q1 w6 x7 P! F- c& h# G
- }
B$ P5 {2 D( Z( ] - }# ?. {( t0 E4 U. a6 L
- }
! w+ S) Z3 l+ Z; y - //Get protocol6 |, S* m8 K) y4 G9 _5 `
- if (!canonicalURL){* \9 F6 r4 I- {0 U3 r9 a( Z2 p
- curProtocol = window.location.protocol.split(':')[0];& t3 k# ?+ q: I! q
- }
0 i3 F0 C' U& r# M - else{- k) P! o1 d9 ]) s J
- curProtocol = canonicalURL.split(':')[0];4 r* [! J$ b, m
- }
" B9 `$ w: C9 X U% W6 l& w - //Get current URL if the canonical URL does not exist+ D8 X3 C# G, r# i% y: c; C
- if (!canonicalURL) canonicalURL = window.location.href;! L7 C" e" D% T1 G! j$ r6 i
- //Assign script content. Replace current URL with the canonical URL
. n N3 r; g: X' i3 _) 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);})();/ V( A% A% v4 `3 M, U, u+ `
- </script>
& W" l: @ h5 N3 w
复制代码 ! H% d3 x; w6 l/ \$ C
' g, B9 x0 a& R! _% p
& n& ]0 s5 F. A& b7 q0 ` |
|