|
|
百度站长平台链接自动提交-js代码- <script>, e( b) z# O. E, x
- (function(){
9 o' {+ O0 Q I9 |2 H - var canonicalURL, curProtocol;4 s2 _* L$ }7 X- K! A% k N
- //Get the <link> tag/ _8 ]8 ?% f0 C2 a6 \
- var x=document.getElementsByTagName("link");( l! I# v* u( B+ [' R( j% x
- //Find the last canonical URL
+ N* n6 l! U( `& E( e- @1 ~ - if(x.length > 0){
8 z- v- o w/ N, C2 R0 } - for (i=0;i<x.length;i++){
" `0 c( y7 d* X" j - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){' K' y: g) M2 L
- canonicalURL=x[i].href;& R2 J3 e% p% X# N6 D% _2 Y/ b4 O
- }
+ Y7 r- B/ c% Z% I! N1 y - }% m. W! K$ m) e# Q. z% p
- }% Y' m. h: B- m* {
- //Get protocol& j( ~5 W. M$ g7 @5 [5 ~! M: D
- if (!canonicalURL){1 R$ s! l1 o- v
- curProtocol = window.location.protocol.split(':')[0];; j. e: r& [- v9 o; o
- }" B8 J/ i' ?6 o
- else{
5 y/ ]3 @) m9 s G; F) V. [ - curProtocol = canonicalURL.split(':')[0]; M2 Z" X" S3 A7 c3 k1 z1 N
- }
; G2 {+ U: P; D( S, @, L3 b w0 } - //Get current URL if the canonical URL does not exist
4 Z, @# ] |' C& ~ |! W3 I7 w - if (!canonicalURL) canonicalURL = window.location.href;
! C; n# H3 }" D- w, g# G! T2 T1 p/ k - //Assign script content. Replace current URL with the canonical URL1 u' Y9 A3 a- P+ U- Z: T
- !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);})();# B' ?: d( g( j4 j5 b6 C; W
- </script> b. _2 I8 V. D0 y! ^
复制代码
6 w/ Y& v5 G y
0 K$ k1 Q/ Q3 g, ?2 R! ?" o, U* N( [9 {) c4 r+ Y' ^) L
|
|