DominicWoo(讨论 | 贡献) |
DominicWoo(讨论 | 贡献) |
||
第4行: | 第4行: | ||
(function(){ | (function(){ | ||
var commentBody = document.getElementsByClassName('comments-body')[0]; | var commentBody = document.getElementsByClassName('comments-body')[0]; | ||
− | + | var commentForm = commentBody.getElementsByTagName('form')[1]; | |
commentBody.removeChild(commentForm); | commentBody.removeChild(commentForm); | ||
commentBody.insertBefore(commentForm, commentBody.childNodes[0]); | commentBody.insertBefore(commentForm, commentBody.childNodes[0]); |
2021年2月23日 (二) 13:17的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ /* 评论区评论表单置顶 */ (function(){ var commentBody = document.getElementsByClassName('comments-body')[0]; var commentForm = commentBody.getElementsByTagName('form')[1]; commentBody.removeChild(commentForm); commentBody.insertBefore(commentForm, commentBody.childNodes[0]); })(); /* 生成音频播放按钮 */ (function(){ var audios = document.getElementsByClassName("audio-player"); for(var i=0;i<audios.length;i++){ var audio = audios[i]; var link = audio.firstElementChild.href; 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); } })();