|
|
百度站长平台链接自动提交-js代码- <script>
8 ~7 i9 O+ a& m/ c% d1 y - (function(){; T/ Q7 Z: L0 R7 T+ h. K- Q. z
- var canonicalURL, curProtocol;" x) J- ^; O* E9 D( z j6 Z
- //Get the <link> tag! c; B* ~6 m$ I& u
- var x=document.getElementsByTagName("link");- o3 Q, B; E, |# R% m* b. S, x! y+ r
- //Find the last canonical URL
& q. {9 Q7 V" p1 w+ N0 l% P+ D' b; Q - if(x.length > 0){
& I0 N' B9 Z2 t. O/ T - for (i=0;i<x.length;i++){# \1 t7 h4 g8 x0 Z/ Q) j3 P
- if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
' L* t4 o% t$ x4 E" U& v* P2 T0 y7 e! V - canonicalURL=x[i].href;
; s2 \. S4 A9 {- E& |! v9 O - }( N1 j2 q* t4 l1 A: f6 d2 R
- }
, E5 d" ~6 P% C9 J! P/ J - }
) V6 C$ Z; v# K; o" j - //Get protocol
' d2 y5 s+ [" @/ `0 R2 ^- F+ Y3 s - if (!canonicalURL){0 e+ t+ Z0 f& H" F7 `
- curProtocol = window.location.protocol.split(':')[0];
0 K. D) {/ ?% n. y& h2 \ - }4 V6 n% z* k4 s$ a
- else{
$ n# ~7 u) l8 w - curProtocol = canonicalURL.split(':')[0];
3 X6 J% }2 d2 Z8 E - }2 H* |5 `* u& @8 Z6 z
- //Get current URL if the canonical URL does not exist
8 P& o- v8 Z8 t3 X6 z - if (!canonicalURL) canonicalURL = window.location.href;
K0 W: {) F9 Z. w. i/ m' j2 | - //Assign script content. Replace current URL with the canonical URL
, } m9 c( r8 }: {* S/ H( a - !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);})();
5 G/ e# S2 [$ k- O7 @ - </script>+ k! W! t, m6 o- t; P- @
复制代码
) y" M2 v N3 g* I9 m3 J0 M+ ]9 T1 u2 D, S/ {
% n# m0 Y5 i8 A# t0 [/ {7 V. v |
|