bilibili Danmaku Disabler

Auto disable bilibili HTML5 player danmaku.

目前為 2020-04-30 提交的版本,檢視 最新版本

// ==UserScript==
// @name                bilibili Danmaku Disabler
// @name:en-US          bilibili Danmaku Disabler
// @name:zh-CN          bilibili 弹幕关闭
// @description         Auto disable bilibili HTML5 player danmaku.
// @description:en-US   Auto disable bilibili HTML5 player danmaku.
// @description:zh-CN   自动关闭哔哩哔哩 HTML5 播放器弹幕.
// @namespace           bilibili-danmaku-disabler
// @version             2020.04.30
// @author              Akatsuki
// @license             MIT License
// @grant               GM_info
// @run-at              document-idle
// @require             https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @require             https://gf.qytechs.cn/scripts/48306-waitforkeyelements/code/waitForKeyElements.js?version=275769
// @match               *://www.bilibili.com/video/*
// @match               *://www.bilibili.com/bangumi/play/*
// @match               *://www.bilibili.com/blackboard/*
// @match               *://player.bilibili.com/*
// ==/UserScript==

'use strict';

var selector_native = {
    "on": "input[class='bui-checkbox']:checked",
    "off": "input[class='bui-checkbox']:not(:checked)"
};

var selector_embed = {
    "on": "div[class~='bilibili-player-video-btn-danmaku'][data-text='打开弹幕']",
    "off": "div[class~='bilibili-player-video-btn-danmaku'][data-text='关闭弹幕']"
}

if (document.location.hostname === 'player.bilibili.com') {
    var selector = selector_embed
} else {
    var selector = selector_native
}

// Disable danmaku when player loaded
function disable_danmaku(player) {
    player[0].click();
};

waitForKeyElements(selector.on, disable_danmaku, false);

// Detect 'm' or 'M' key to control danmaku on/off
function switch_danmaku() {
    if (document.querySelector(selector.on) !== null) {
        // Switch danmaku on -> off
        document.querySelector(selector.on).click();
    }
    else if (document.querySelector(selector.off) !== null) {
        // Switch danmaku off -> on
        document.querySelector(selector.off).click();
    }
};

$(document).keypress(function (key) {
    // detect 'm' or 'M' key
    if (key.which === 77 || key.which === 109) {
        switch_danmaku();
    }
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址