Greasy Fork

Greasy Fork is available in English.

B站沉浸式观影:隐藏接下来播放推荐

自动隐藏B站视频页的“接下来播放”推荐区,打造极致沉浸体验

// ==UserScript==
// @name         B站沉浸式观影:隐藏接下来播放推荐
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  自动隐藏B站视频页的“接下来播放”推荐区,打造极致沉浸体验
// @author       hoshiki
// @match        https://www.bilibili.com/video/*
// @icon         https://www.bilibili.com/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 创业思维:自动化、极简、专注用户体验
    function hideNextUp() {
        // B站“接下来播放”推荐区的常见选择器
        const selectors = [
            '.bpx-player-ending-panel', // 新版播放器的推荐区
            '.bilibili-player-ending-panel-box', // 旧版播放器的推荐区
            '.bpx-player-recommend', // 右侧推荐
            '.bilibili-player-recommend' // 备用
        ];
        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                el.style.display = 'none';
            });
        });
    }

    // 观察DOM变化,动态隐藏(应对B站的异步加载)
    const observer = new MutationObserver(hideNextUp);
    observer.observe(document.body, { childList: true, subtree: true });

    // 首次加载时也执行一次
    hideNextUp();
})();