您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
哔哩哔哩关灯添加到视频右键
当前为
// ==UserScript== // @name 哔哩哔哩关灯 // @namespace http://tampermonkey.net/ // @description 哔哩哔哩关灯添加到视频右键 // @version 0.1 // @author tomiaa // @match *://www.bilibili.com/video/* // ==/UserScript== ; (() => { console.clear() let isAppend = false; const player = document.getElementById('bilibiliPlayer') let observer = new MutationObserver(() => { console.log(123); if(isAppend) return observer.disconnect(); let menu = player.getElementsByClassName('bilibili-player-context-menu-container'); if(!menu.length ) return; if(!Array.from(menu[1].classList).includes('active')) return; let ul = menu[1].children[0]; let li = document.createElement('li'); li.className = 'context-line context-menu-function'; let a = document.createElement('a'); a.className = 'context-menu-a js-action'; a.innerHTML = '关 灯'; li.appendChild(a); let isGuandeng = false; li.addEventListener('click', () => { let mask = document.getElementById('heimu') let player = document.getElementById('bilibiliPlayer'); if(!isGuandeng){ a.innerHTML = '开 灯'; mask.style.display = 'block'; player.classList.add('mode-light-off'); }else{ a.innerHTML = '关 灯'; mask.style.display = 'none'; player.classList.remove('mode-light-off'); } isGuandeng = !isGuandeng; }) ul.appendChild(li); isAppend = true; }); observer.observe(player,{ childList: true, subtree: true, }) })();