bilibili直播隐藏底部弹幕

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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
            }
        }
    }
})();