Greasy Fork

Greasy Fork is available in English.

BiliBili一键关灯

点击按钮可使视频实现一键关灯模式

当前为 2024-06-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         BiliBili一键关灯
// @version      0.0.5
// @description  点击按钮可使视频实现一键关灯模式
// @author       GSK
// @include      *://*.bilibili.com/*
// @ico          https://www.bilibili.com/favicon.ico?v=1
// @grant    GM_setValue
// @grant    GM_getValue
// @license      MIT License
// @namespace http://greasyfork.icu/users/1321187
// ==/UserScript==


(function() {

    'use strict';
    function hotkey() {
        //接收指令
        var a = window.event.keyCode;
        //判断是否与目标码相同
        //按键A:视频关灯
        if (a == 65) {
            //关灯
            document.getElementsByClassName("bui-checkbox-input")[3].click();
        }
        //按键S:番剧关灯
        if (a == 83) {
            //关灯
            document.getElementsByClassName("bui-checkbox-input")[1].click();
        }
        //按键Z:电影关灯
        if (a == 90) {
            //获取div
            var div = document.getElementsByClassName("fixed-header")[0];
            //关灯
            document.getElementsByClassName("bui-checkbox-input")[1].click();
            //删除div
            div.parentNode.removeChild(div);

        }
    }
    document.onkeydown = hotkey;
    // Your code here...
})();