您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
自动关闭哔哩哔哩 HTML5 播放器弹幕.
当前为
// ==UserScript== // @name:en-US bilibili-Danmaku-Gate // @name B站弹幕关闭 // @description:en-US Auto disable bilibili HTML5 player danmaku. // @description 自动关闭哔哩哔哩 HTML5 播放器弹幕. // @namespace http://greasyfork.icu/users/135090 // @version 2022.02.16 // @author Akatsuki Rui // @license MIT License // @grant GM_info // @run-at document-idle // @description fork from 374051,https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js // @match *://www.bilibili.com/*video/* // @match *://www.bilibili.com/bangumi/play/* // @match *://www.bilibili.com/blackboard/* // @match *://www.bilibili.com/html/player.html* // @match *://player.bilibili.com/* // ==/UserScript== "use strict"; const SELECTOR_NATIVE = { on: "input:checked[class='bui-switch-input']", off: "input:not(:checked)[class='bui-switch-input']", }; const SELECTOR_EMBED = { on: "div[class~='bilibili-player-video-btn-danmaku'][data-text='打开弹幕']", off: "div[class~='bilibili-player-video-btn-danmaku'][data-text='关闭弹幕']", }; const IS_EMBED = document.location.hostname === "player.bilibili.com"; const SELECTOR = IS_EMBED ? SELECTOR_EMBED : SELECTOR_NATIVE; // Skip Charge Support function skipCharge() { const skip = () => { setTimeout(() => { document .getElementsByClassName("bilibili-player-electric-panel-jump")[0] .click(); }, 10); }; const videoElementA = document.querySelector("video"); const videoElementB = document.querySelector("bwp-video"); if (videoElementA) { videoElementA.onended = skip; } else if (videoElementB) { videoElementB.onended = skip; } } // Disable danmaku function disableDanmaku() { const button = document.querySelector(SELECTOR.on); if (button) { button.click(); skipCharge(); } if (!document.querySelector(SELECTOR.off)) { setTimeout(disableDanmaku, 500); } } // Disable danmaku with PJAX detector function disableDanmakuPJAX() { const obServer = new MutationObserver(disableDanmaku); const obTarget = document.getElementById("bilibili-player"); const obOption = { childList: true }; disableDanmaku(); obServer.observe(obTarget, obOption); } // Redirect `bilibili.com/s/video/*` to `bilibili.com/video/*` if (location.href.includes("/s/video/")) { location.replace(location.href.replace("/s/video/", "/video/")); } // Run disabler IS_EMBED ? disableDanmaku() : disableDanmakuPJAX();