Greasy Fork is available in English.

B站弹幕hook

1.关闭智能云屏蔽 2.关闭高赞弹幕 3.关闭大会员弹幕

// ==UserScript==
// @name         B站弹幕hook
// @version      0.2
// @description  1.关闭智能云屏蔽 2.关闭高赞弹幕 3.关闭大会员弹幕
// @author       DeltaFlyer
// @copyright    2024, DeltaFlyer(https://github.com/DeltaFlyerW)
// @license      MIT
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/bangumi/play/*
// @run-at       document-start
// @grant        unsafeWindow
// @icon         https://www.biliplus.com/favicon.ico
// @require      https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.0/jszip.min.js
// @namespace    https://greasyfork.org/users/927887
// ==/UserScript==


if (!unsafeWindow.Map.prototype._set) {
    unsafeWindow.Map.prototype._set = unsafeWindow.Map.prototype.set
    unsafeWindow.Map.prototype.set = function (key, value) {
        if (key && key.danmakuStore) {
            let bpx_player = key
            if (!bpx_player.danmakuStore._fetchDmSeg) {
                unsafeWindow.bpx_player = window.bpx_player = bpx_player
                console.log(key, value)
                let danmakuStore = bpx_player.danmakuStore
                danmakuStore._fetchDmSeg = danmakuStore.fetchDmSeg
                danmakuStore.fetchDmSeg = async function () {
                    let result = await danmakuStore._fetchDmSeg(...arguments)
                    try{
                        for (let danmaku of result.details.elems) {
                            danmaku.weight = 11 // 关闭智能云屏蔽
                            danmaku.attr = 1048576 // 关闭高赞弹幕
                            danmaku.colorful = undefined // 关闭大会员弹幕
                        }
                    }
                    catch(e){
                        console.log(e)
                    }
                    console.log(result)
                    return result
                }
            }
        }
        this._set(key, value)
    }
}