注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件。
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ /* 加载Mobile.css */ mw.loader.using('mobile.site.styles'); /* 处理直接下载的链接问题 */ $('.download-link > a').each(function (_, n) { n.setAttribute('target', '_blank'); n.setAttribute('download', n.getAttribute('title')); n.setAttribute('title', '下载'); }); /* 生成音频播放按钮 */ (function(){ var audios = document.getElementsByClassName('audio-player'); var notValidAudio = /wpDestFile/; for(var i=0;i<audios.length;i++){ var audio = audios[i]; var linkEl = audio.firstElementChild; if (!linkEl) { continue; } var link = linkEl.href; if(notValidAudio.test(link)) continue; audio.innerHTML = ''; audio.classList.add('has-audio-element'); var a = document.createElement('audio'); a.src = link; a.preload = 'none'; a.onended = function(){ this.parentNode.classList.remove('audio-player-playing'); }; var button = document.createElement('button'); button.classList.add('audio-player-button'); button.append(a); button.onclick = function(){ var a = this.firstElementChild; if (a.paused){ a.play(); this.classList.add('audio-player-playing'); this.classList.remove('audio-player-paused'); }else{ a.pause(); this.classList.add('audio-player-paused'); this.classList.remove('audio-player-playing'); }; }; audio.append(button); }; })(); /* 生成音频播放-s按钮 */ (function (){ var audios = document.getElementsByClassName('audio-player-s'); var notValidAudio = /wpDestFile/; var currentPlaying = null; for(var i = 0; i < audios.length; i++) { var audio = audios[i]; var linkEl = audio.firstElementChild; if (!linkEl) { continue; } var link = linkEl.href; if (notValidAudio.test(link)) { continue; } audio.innerHTML = ''; audio.classList.add('has-audio-element'); var a = document.createElement('audio'); a.src = link; a.preload = 'none'; a.onended = function () { currentPlaying = null; this.parentNode.classList.remove('audio-player-playing-s'); }; var button = document.createElement('button'); button.classList.add('audio-player-button-s'); button.append(a); button.onclick = function () { var a = this.firstElementChild; if (currentPlaying != null && currentPlaying != a) { currentPlaying.pause(); currentPlaying.currentTime = 0; currentPlaying.parentNode.classList.remove('audio-player-playing-s'); } if (a.paused) { a.play(); currentPlaying = a; this.classList.add('audio-player-playing-s'); this.classList.remove('audio-player-paused-s'); } else { a.pause(); this.classList.add('audio-player-paused-s'); this.classList.remove('audio-player-playing-s'); }; }; audio.append(button); }; })(); /* 移除渲染延迟 Cloak */ $('.template-render-cloak').each(function(_, n) { n.classList.remove('template-render-cloak'); });