|
|
百度站长平台链接自动提交-js代码- <script>
/ ?, a" K9 L) U. s0 f2 z4 B - (function(){) a2 A' F3 m5 `) V' w$ \8 J x% {2 P2 `
- var canonicalURL, curProtocol;0 N" r B5 h* k$ d5 T( u
- //Get the <link> tag
' Z! Q& A1 ^. A2 Y5 u - var x=document.getElementsByTagName("link");
# ?- o5 V/ \* b6 N! R - //Find the last canonical URL
$ g+ Q# x7 f0 `5 u - if(x.length > 0){
]! V5 F6 F1 j/ ^: d& T - for (i=0;i<x.length;i++){0 p+ ]! y) l, J
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
% D \- ^* c& o9 z( b. U - canonicalURL=x[i].href;; n3 |6 R8 E! w% ^
- }( c1 N3 v$ I, G# d& O- n
- }
0 I9 N: H. K- X# I, ?# a% M: z - }8 k8 C8 b: N) }/ q+ Q+ f w
- //Get protocol
1 x) C! p$ \! n. x% H5 K) N, l - if (!canonicalURL){/ X6 f7 e) z6 N4 M0 `4 r
- curProtocol = window.location.protocol.split(':')[0];
! L1 Q9 M2 o; {+ G - }' D& U/ D$ B1 f4 s: B g
- else{; q/ B. f2 T; P8 D# _8 x
- curProtocol = canonicalURL.split(':')[0];
/ D- m9 Q3 D2 g3 |; H - }) J0 m1 ^" i" x" y( L. V, G
- //Get current URL if the canonical URL does not exist; Y) a3 |: b% r( N0 j2 r
- if (!canonicalURL) canonicalURL = window.location.href;
4 u1 `$ s+ v7 \/ x, w* ` - //Assign script content. Replace current URL with the canonical URL5 h7 ?+ r( v* [" I0 G1 ?1 v/ 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);})();9 w4 I' X3 z: y3 @' Y* |
- </script>
" T9 n# }8 N8 p+ [
复制代码 ! }7 @5 n9 w5 q5 C5 D" ^
$ r+ x" W; a; Z) P& C
+ T+ P) l1 s6 R& O |
|