Greasy Fork

Greasy Fork is available in English.

BiliBili 隐藏所有与视频无关的元素

总是感觉B站界面内容太复杂,太多诱惑。这个脚本只保留了最基本的视频播放功能,避免丢失焦点,减少无意义的时间消耗

// ==UserScript==
// @name         BiliBili 隐藏所有与视频无关的元素
// @namespace    http://tampermonkey.net/
// @version      0.71
// @description  总是感觉B站界面内容太复杂,太多诱惑。这个脚本只保留了最基本的视频播放功能,避免丢失焦点,减少无意义的时间消耗
// @author       You cunkai
// @match        *://www.bilibili.com/video/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const theMask = document.createElement("div")
    theMask.style.cssText = `
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        background-color: white;
        z-index: 8;
    `
    document.body.appendChild(theMask)

    const styleSheetText = `
        .left-container {
            position: static !important;
            z-index: initial !important;
        }

        #playerWrap {
            z-index: 11;
        }

        #multi_page, #danmukuBox, #v_desc, #arc_toolbar_report{
            z-index: 10;
        }

        .right-container-inner{
            position: static !important;
        }

        #danmukuBox, #arc_toolbar_report {
            position: relative !important;
        }

        .video-pod {
            display: block !important;
            visibility: visible !important;
            z-index: 10 !important;
            position: relative !important;
        }


        .ad-report, .bpx-player-ending-panel{
            display: none !important;
        }

    `
    const addOnStyleSheet = document.createElement("style")
    addOnStyleSheet.innerHTML = styleSheetText
    document.body.appendChild(addOnStyleSheet)

    localStorage.setItem("recommend_auto_play", "close")


    function clearAttributes() {
        const input = document.querySelector('.nav-search-input');
        if (input) {
            input.setAttribute('placeholder', '');
            input.setAttribute('title', '');
        }
    }

    // 页面加载后执行一次
    clearAttributes();

    // 监听 DOM 变化,确保后续动态加载也处理
    const observer = new MutationObserver(clearAttributes);
    observer.observe(document.body, { childList: true, subtree: true });


    // Your code here...
})();