Smooth YouTube livestream

5/11/2025, 9:27:12 PM

目前為 2025-05-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name                Smooth YouTube livestream
// @namespace           UserScripts
// @version             0.1.0
// @license             MIT License
// @match               https://www.youtube.com/*
// @grant               none
// @author              -
// @description         5/11/2025, 9:27:12 PM
// ==/UserScript==

document.addEventListener('canplay', (e)=>{
    if(!e || !e.isTrusted || !(e.target instanceof HTMLMediaElement)) return;
    const p = document.querySelector('.ytp-live-badge.ytp-live-badge-is-livehead');
    if(p){
        const media = e.target;
        setTimeout(()=>{
            if(media.isConnected && media.matches('#player *, #ytd-player *') && media.playbackRate === 1 && p === document.querySelector('.ytp-live-badge.ytp-live-badge-is-livehead')){
                media.playbackRate = 0.968;
                setTimeout(()=>{
                    // L = n * 1 - n * 0.968
                    if(media.playbackRate === 0.968){
                        media.playbackRate = 1;
                    }
                }, 30000)
            }
        }, 100);
    }
}, true);