RTX Video fix

使用小面积模糊遮罩干扰 RTX Video,解决倍速播放视频时对显卡带来的过度负载

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         RTX Video fix
// @name:en         RTX Video fix
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  使用小面积模糊遮罩干扰 RTX Video,解决倍速播放视频时对显卡带来的过度负载
// @description:en  Use a small-area blur overlay to interfere with RTX Video and alleviate excessive GPU load during high-speed video playback.
// @match        *://*/*
// @grant        none
// @license      GPL-v3
// ==/UserScript==

(function () {
    'use strict';

    const OVERLAY_ID = '__bili_hdr_corner_blur__';

    function tryInjectOverlay() {
        const video = document.querySelector('video');
        const wrap = document.querySelector('.bpx-player-video-wrap');
        if (!video || !wrap) return;

        let overlay = document.getElementById(OVERLAY_ID);
        const rate = video.playbackRate;

        if (rate > 1.0 && !overlay) {
            const rect = wrap.getBoundingClientRect();

            // 设定遮罩尺寸(右下角 120x120)
            const size = 1;

            overlay = document.createElement('div');
            overlay.id = OVERLAY_ID;
            Object.assign(overlay.style, {
                position: 'fixed',
                left: `${rect.right - size}px`,
                top: `${rect.bottom - size}px`,
                width: `${size}px`,
                height: `${size}px`,
                backdropFilter: 'blur(1px)',
                webkitBackdropFilter: 'blur(1px)',
                pointerEvents: 'none',
                zIndex: '99999999',

            });
            document.body.appendChild(overlay);
            console.log('[HDR控制] 小角落模糊遮罩已插入');
        } else if (rate === 1.0 && overlay) {
            overlay.remove();
            console.log('[HDR控制] 模糊遮罩已移除');
        }

        // 实时跟随播放器位置
        if (overlay && wrap) {
            const rect = wrap.getBoundingClientRect();
            const size = 120;
            Object.assign(overlay.style, {
                left: `${rect.right - size}px`,
                top: `${rect.bottom - size}px`
            });
        }
    }

    setInterval(tryInjectOverlay, 50);
})();