|
|
百度站长平台链接自动提交-js代码- <script>* p$ Q/ I7 _4 g: T( o ]) g- v! ?
- (function(){
' N$ T1 d7 x2 p; ]5 y0 o, N - var canonicalURL, curProtocol;- _5 j0 e9 h" J1 g! r
- //Get the <link> tag
7 q0 I% j. r( H+ W& B) q - var x=document.getElementsByTagName("link");
% c$ k# R. }0 S" m5 Q - //Find the last canonical URL F& c0 d# {7 K, n
- if(x.length > 0){
# ~& v% h8 @7 d2 d8 s( R - for (i=0;i<x.length;i++){4 _$ r. R1 U# q* N0 A; V9 w
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
) b# c) w( O1 _3 u2 \- ^3 ? g - canonicalURL=x[i].href;# C5 v& [% d; q( J+ L8 j# y6 k$ d
- }3 |8 x7 T. [5 Y5 s8 W* q
- }
& L7 l9 V$ Y; }, E - }
5 ~9 c4 L! M' L) S8 Y% e - //Get protocol X6 D! ?+ W6 ^9 P8 c
- if (!canonicalURL){' q" c4 k; X' p! J# s" y/ a
- curProtocol = window.location.protocol.split(':')[0];
1 g# ~% F6 S! F' F0 p! R8 u - }3 ?+ b) C$ t; X: H: R3 @: {
- else{4 S2 Y! j' P6 N' k5 l+ B: G( ^
- curProtocol = canonicalURL.split(':')[0];! v. O& T! k3 |; o* ]6 J
- }
9 d( n9 z+ H" Z( I, t/ T - //Get current URL if the canonical URL does not exist
! X S) M) g% ^7 S - if (!canonicalURL) canonicalURL = window.location.href;
' V3 p8 O' T! O - //Assign script content. Replace current URL with the canonical URL7 ~! N5 Z% D( }; g- g B
- !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);})();
$ l" e& C" ]/ E. b [; Q5 {8 F - </script>
* h5 Q: [* J+ g! T$ Z
复制代码
# Z& i% [. @. e i: g# a) [4 l8 A# E( I! P6 i( g
c# H! Y. a( v# z; C' s1 ^- J |
|