|
百度站长平台链接自动提交-js代码- <script>. v" d( k5 ?% H
- (function(){
, w8 [* y: X7 c( X$ y5 ]9 [ - var canonicalURL, curProtocol;' z2 U n/ I$ n$ P
- //Get the <link> tag
4 N" r0 A* N' a: h - var x=document.getElementsByTagName("link");
* s5 v; [2 |6 U/ f0 L# j/ ]! C8 H - //Find the last canonical URL
, N. D% ~' [; w* p+ Z; T$ R5 c - if(x.length > 0){
2 r9 H1 i$ U( d+ Z8 ` - for (i=0;i<x.length;i++){$ m# R8 r1 L* x
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){# I- m7 F) ~/ \4 |# C1 X* @6 H% X
- canonicalURL=x[i].href;6 ^$ y; e2 ^' \3 \# B8 D5 [
- }1 i$ S- o/ e# ^+ d) s
- }
: r0 r% S/ }0 n8 Y' I& a - }
- t# L# I o* J$ O0 [ - //Get protocol6 O6 Q$ m# Z0 I
- if (!canonicalURL){
$ e h, ]/ J% ]$ M. Q7 R - curProtocol = window.location.protocol.split(':')[0];
& ?3 [- v* f V - }. ]3 |8 w ^6 u3 c2 Y$ h% K l
- else{
0 t- X2 Y s k- _1 t4 i% r - curProtocol = canonicalURL.split(':')[0];
' i+ R/ ?3 T# {7 j* V8 ?' m - }
1 B5 j5 A- ^; o6 s/ W {. V - //Get current URL if the canonical URL does not exist: f: m6 q' i# p3 L
- if (!canonicalURL) canonicalURL = window.location.href;( g1 n* S/ P1 ^: e$ F8 M
- //Assign script content. Replace current URL with the canonical URL
6 N+ Q& h& o, T7 Y; T d - !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);})();
; @; ]# ~, ~$ t3 J- v - </script>, i! Q- V2 k( S2 E, T1 Y
复制代码 , ]+ _ m, K1 l2 v* ^$ [
$ r, K- A: g4 Q" M( @& E
8 b) Q/ [7 B$ l
|
|