// ==UserScript== // @name 哔哩哔哩弹幕一键隐藏(简化版) // @namespace http://tampermonkey.net/ // @version 2.0 // @description 一键隐藏/显示B站全部弹幕 // @author Assistant // @match https://www.bilibili.com/video/* // @match https://www.bilibili.com/bangumi/play/* // @icon https://www.bilibili.com/favicon.ico // @grant GM_addStyle // @license MIT // ==/UserScript== (function() { 'use strict'; // 添加全局样式,用于隐藏弹幕 GM_addStyle(` .bili-danmaku-hidden canvas, .bili-danmaku-hidden .bpx-player-danmaku, .bili-danmaku-hidden [class*="danmaku"] { opacity: 0 !important; visibility: hidden !important; } `); // 创建按钮 function addButton() { if (document.getElementById('my-danmaku-toggle')) return; const btn = document.createElement('div'); btn.id = 'my-danmaku-toggle'; btn.innerHTML = '💬 隐藏弹幕'; btn.style.cssText = ` position: fixed; bottom: 80px; right: 20px; z-index: 99999; background: rgba(0,0,0,0.7); color: white; padding: 8px 16px; border-radius: 20px; font-size: 14px; cursor: pointer; backdrop-filter: blur(5px); font-family: system-ui; `; let hidden = false; btn.onclick = () => { hidden = !hidden; if (hidden) { document.body.classList.add('bili-danmaku-hidden'); btn.innerHTML = '💬 显示弹幕'; btn.style.background = 'rgba(0,100,0,0.8)'; } else { document.body.classList.remove('bili-danmaku-hidden'); btn.innerHTML = '💬 隐藏弹幕'; btn.style.background = 'rgba(0,0,0,0.7)'; } }; document.body.appendChild(btn); } // 等待页面加载 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', addButton); } else { addButton(); } })();