avatar
匿名用户
×
创建一个新的页面
输入页面标题:
目前语音维基上有2057个页面。 在上方输入您想创建的页面名称或单击以下标题之一,即可开始撰写!



语音维基

MediaWiki:Mobile.js

DominicWoo讨论 | 贡献2021年2月24日 (三) 21:19的版本

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-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');

/* 评论区评论表单置顶 */
(function(){
    var commentBody = document.getElementsByClassName('comments-body')[0];
    if(commentBody == null) return;
    var commentForm = commentBody.getElementsByTagName('form')[1];
    commentBody.removeChild(commentForm);
    commentBody.insertBefore(commentForm, commentBody.childNodes[0]);
})();

/* 生成音频播放按钮 */
(function(){
            var audios = document.getElementsByClassName("audio-player");
            var notValidAudio = /wpDestFile/;
            for(var i=0;i<audios.length;i++){
                var audio = audios[i];
                var link = audio.firstElementChild.href;
                if(notValidAudio.test(link)) continue;
                audio.innerHTML = "";
                var a = document.createElement('audio');
                a.src = link;
                a.preload = 'none';
                audio.append(a);
                var button = document.createElement('button');
                button.onclick = function(){
                    var audio = this.parentNode;
                    var a = audio.children[0];
                    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');
                    };
                };

                a.onended = function(){
                    this.parentNode.children[1].classList.remove('audio-player-playing');
                };

                audio.append(button);
            };
})();

/* 生成b站播放窗口 */
(function(){
            var bVideos = document.getElementsByClassName("bilibili");
            for(var i=0;i<bVideos.length;i++){
                var bVideo = bVideos[i];
                var bvid = bVideo.textContent.trim();
                bVideo.innerHTML = "";
                var iframe = document.createElement('iframe');
                iframe.src = "https://player.bilibili.com/player.html?page=1&bvid=" + bvid;
                iframe.scrolling = "no";
                iframe.border = "0";
                iframe.frameborder = "no";
                iframe.framespacing="0"; 
                iframe.allowfullscreen="true";
                bVideo.append(iframe);
            }
})();

(function(){
    var collapsible = document.getElementsByClassName('collapsible-heading');
    for(var i=0;i<collapsible.length;i++) 
        collapsible[i].classList.add('open-block');
    var collapsible = document.getElementsByClassName('ollapsible-block');
    for(var i=0;i<collapsible.length;i++) 
        collapsible[i].classList.add('open-block');
})();