bilibili直播隐藏底部弹幕

bilibili直播隐藏底部弹幕 b站直播隐藏底部弹幕

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            bilibili直播隐藏底部弹幕
// @namespace       https://github.com/RengeRenge
// @version         2024102700
// @description     bilibili直播隐藏底部弹幕 b站直播隐藏底部弹幕
// @author          RengeRenge
// @license         MIT
// @match           *://live.bilibili.com/*
// @icon            https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@preview/images/logo-small.png
// @icon64          https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@preview/images/logo.png
// @grant           none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    let timer = setInterval(() => {
        if (start()) {
            clearInterval(timer)
        }
    }, 2000)

    function start() {
        const targetNode = document.getElementsByClassName('danmaku-item-container')[0]
        console.log("found danmaku-item-container result", targetNode)
        if (!targetNode) {
            return 0
        }
        const observer = new MutationObserver((mutationsList) => {
            for (let mutation of mutationsList) {
                if (mutation.type === 'childList') {
                    mutation.addedNodes.forEach(node => {
                        observeDanmu(node)
                    })
                    hiddenBottomDanmu()
                }
            }
        })
        const config = { childList: true}
        observer.observe(targetNode, config)
        return 1

        function observeDanmu(node) {
            const observer = new MutationObserver((mutationsList) => {
                for (let mutation of mutationsList) {
                    if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
                        hiddenBottomDanmu()
                    }
                }
            })

            const config = { attributes: true, className: true, characterData: true }
            observer.observe(node, config)
        }

        function hiddenBottomDanmu() {
            for (const obj of document.getElementsByClassName('bili-danmaku-x-center')) {
                obj.style.opacity = 0
            }
        }
    }
})();