|
|
百度站长平台链接自动提交-js代码- <script>' \) S3 V# n$ p- D7 I) A: o7 m
- (function(){
! J! y# Y" c- ?* S: c+ \6 c - var canonicalURL, curProtocol;$ J: O1 I+ v$ h4 o5 M$ t
- //Get the <link> tag
- F+ u; n# N6 b1 t - var x=document.getElementsByTagName("link");
+ D5 n: @+ D% {% Z h2 Y0 v - //Find the last canonical URL, }, m- x' N, V. b, J
- if(x.length > 0){
% O- E: @' Z; _0 D+ [ - for (i=0;i<x.length;i++){
- k0 s& e" E5 A! o& B7 r; y - if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
. I) s$ q5 C: z& `6 `% H - canonicalURL=x[i].href;
f/ f4 } H H8 j' E1 Q. I2 a, q - }; z, V! m( d9 L3 U+ w _* Z
- }' L% g0 m! L, m, B5 E
- }4 t" B! {% _# {6 t. b0 x: K+ Z( z& }3 X) i
- //Get protocol
: g! ]; X0 ^0 P$ l5 X, y' [ - if (!canonicalURL){
+ ^8 D+ `) r. X, J - curProtocol = window.location.protocol.split(':')[0];4 s4 d' b$ ^. u# E" q
- }# H, u) c6 W- M; ~0 j
- else{
8 g4 N# k; f, ~ L5 I, E* ?1 N - curProtocol = canonicalURL.split(':')[0];
; c$ K$ e0 d$ r2 p% L6 n. x - }" A; I0 ^" W2 _* ?9 z7 }5 x
- //Get current URL if the canonical URL does not exist
6 y& {) b5 L8 u+ R3 `8 q - if (!canonicalURL) canonicalURL = window.location.href;
: v/ J1 B' K, |6 Q$ z1 w8 H - //Assign script content. Replace current URL with the canonical URL) h W+ C2 J0 F) Z/ \8 }. J
- !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);})();
8 i) k, `1 [# A$ K( B - </script>+ c1 x1 b+ c6 n/ W) L' e
复制代码 6 O% \7 L& P; i
$ o, U5 ]$ x6 e% t% T2 w: G) K$ [2 a* q. q7 O" E( P
|
|