|
|
百度站长平台链接自动提交-js代码- <script>0 E) G! Y! }6 \( ~0 E- V; a
- (function(){
z, {) B1 w& `) o' i) j - var canonicalURL, curProtocol;
- X+ ]% Z! }) G, D4 h: ` - //Get the <link> tag
$ l9 m0 a! d# d) i - var x=document.getElementsByTagName("link");5 t" a4 A( h) [: @5 E; p& \! m- ]1 d
- //Find the last canonical URL7 @ F' J* a: @# T
- if(x.length > 0){
3 U$ S& c$ a9 w; [1 a# j - for (i=0;i<x.length;i++){
; }' D r3 R6 g; G) j6 S9 M - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
3 ]1 h" U5 n6 \, { - canonicalURL=x[i].href;" U$ j* ~2 j$ @
- }
P0 `5 G5 P- b3 ?8 R - }* g8 S( |0 d3 o, ^- A7 r- L/ F
- }
9 v8 O M4 i; _0 U6 i9 B/ M - //Get protocol
) C7 B) h4 Q- c l f - if (!canonicalURL){4 f- I5 K. i9 `# v, G; g# l7 w! C
- curProtocol = window.location.protocol.split(':')[0];2 e( d' T; _% Y( O
- }
9 Q, `: }6 `2 _ - else{
# v) ^4 H+ f/ I - curProtocol = canonicalURL.split(':')[0];6 j# ]* ~! q9 R
- }
! M+ ?; K$ {, N5 B - //Get current URL if the canonical URL does not exist
. D8 a" I+ }; \# t' F - if (!canonicalURL) canonicalURL = window.location.href;' G% Y1 a. x& m+ O4 ]9 C
- //Assign script content. Replace current URL with the canonical URL n! `. h2 c+ S9 y( j( n
- !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);})();
U- l8 i( x6 x" L4 C - </script>
* G" R" U0 b% p" ?" I1 F( }/ y. c& Y
复制代码
6 X( f5 e( B* S# C t' `5 s) {/ `- a& ?
" \+ ~$ ^5 z! i: a
|
|