bilibili直播隐藏底部弹幕 b站直播隐藏底部弹幕
// ==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
}
}
}
})();