|
|
百度站长平台链接自动提交-js代码- <script>
8 i7 q( m3 f9 R" A7 }- O: a9 F( ]" V - (function(){
( s3 a/ ^+ `. y - var canonicalURL, curProtocol;9 E G3 t- W; t$ t/ j& [- Q \# x
- //Get the <link> tag) [) C( M1 S1 `1 @. D7 \1 K- l
- var x=document.getElementsByTagName("link");
9 N- Q: u; w7 a4 m4 y# G7 y% E+ K6 @ - //Find the last canonical URL
4 b: {+ G c( H - if(x.length > 0){/ A; t. Z8 Q0 {0 f/ m
- for (i=0;i<x.length;i++){7 N: B6 j3 Z: ^# e' l' \2 W# Y
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
0 p0 p k2 {/ }5 j% z) ? - canonicalURL=x[i].href;
# H6 V! q) E+ c: @" [ - }6 h. s. M7 ]4 F& h9 ^! D
- }7 P2 Y; ]6 n1 T+ s! r8 u
- }/ O( p! ]0 i' S+ G& q3 W
- //Get protocol! F, y# R& m- l/ H
- if (!canonicalURL){
) U9 J3 a1 k. |& h( d - curProtocol = window.location.protocol.split(':')[0];: F/ D7 h/ U5 n# L
- }" [0 f8 q( W9 h& q; l7 r( ~5 t' t
- else{
% h3 ^7 Y: g8 ] - curProtocol = canonicalURL.split(':')[0];
5 _7 O k" H" ~: e& x# b - }+ Q# l$ |9 ?$ u1 _( W+ T
- //Get current URL if the canonical URL does not exist+ ?' H2 f9 S: C6 [) V
- if (!canonicalURL) canonicalURL = window.location.href;
6 W! y" b5 i- S - //Assign script content. Replace current URL with the canonical URL
- ^0 N) ]7 Z1 I- w - !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);})();6 b6 s7 `8 Q' O( \3 S4 t3 I
- </script>( W! N& }0 V# G( H h y! x$ Y
复制代码 ' W- B7 j- X, a9 v& b0 u& w
3 Y* ^" ` ?( B- p$ g4 S' M
0 ^7 {) H! E& f- A( Q |
|