哔哩哔哩视频背景变白,按减号关灯模式,G键切宽屏/网页全屏,ESC恢复

按0旁边的减号

目前為 2023-05-30 提交的版本,檢視 最新版本

// ==UserScript==
// @name         哔哩哔哩视频背景变白,按减号关灯模式,G键切宽屏/网页全屏,ESC恢复
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  按0旁边的减号
// @author       cjm
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/list/watchlater*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    function addCSS(cssText) {
        var style = document.createElement('style')
        , //创建一个style元素
            head = document.head || document.getElementsByTagName('head')[0];
        //获取head元素
        style.type = 'text/css';
        //这里必须显示设置style元素的type属性为text/css,否则在ie中不起作用
        if (style.styleSheet) {
            //IE
            var func = function() {
                try {
                    //防止IE中stylesheet数量超过限制而发生错误
                    style.styleSheet.cssText = cssText;
                } catch (e) {}
            }
            //如果当前styleSheet还不能用,则放到异步中则行
            if (style.styleSheet.disabled) {
                setTimeout(func, 10);
            } else {
                func();
            }
        } else {
            //w3c
            //w3c浏览器中只要创建文本节点插入到style元素中就行了
            var textNode = document.createTextNode(cssText);
            style.appendChild(textNode);
        }
        head.appendChild(style);
        //把创建的style元素插入到head中
    }


    addCSS(`
    #bilibili-player-placeholder-top,.bpx-player-video-area {background-color:white;}
.111bpx-player-video-wrap{width:65%;}
.ad-report.ad-floor-exp{display:none !important;}
`)

    let currentStateIndex = 0; // 当前状态的索引
    const actions = [
        ()=>{document.querySelector('div[aria-label="宽屏"]')?.click();},
        ()=>{document.querySelector('div[aria-label="网页全屏"]')?.click()},
    ]; // 所有的状态

    document.addEventListener('keydown', function(event) {
        if (event.keyCode === 189/*减号*/) {
            document.querySelector('input[aria-label="关灯模式"]').click();
        }else if(event.keyCode === 71/*G*/){
            const currentAction = actions[currentStateIndex % actions.length]; // 获取当前状态
            currentAction();
            currentStateIndex++; // 切换到下一个状态
        }
    });


})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址