YTBetter - Enable Rewind/DVR

Unlocks rewind for YouTube live streams with disabled DVR

התקן את הסקריפט?
סקריפטים מומלצים של יוצר זה

אולי תאהב גם את YouTube All Videos Playlists (YAVP).

התקן את הסקריפט
// ==UserScript==
// @name         YTBetter - Enable Rewind/DVR
// @namespace    YTBetter
// @version      2.4
// @description  Unlocks rewind for YouTube live streams with disabled DVR
// @description:ru  Позволяет перематывать YouTube-стримы, где такая возможность заблокирована
// @author       copyMister
// @match        https://www.youtube.com/*
// @match        https://m.youtube.com/*
// @run-at       document-start
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

"use strict";

// Interop with "Simple YouTube Age Restriction Bypass"
const {
    get: getter,
    set: setter,
} = Object.getOwnPropertyDescriptor(Object.prototype, "playerResponse") ?? {
    set(value) {
        this[Symbol.for("YTBetter")] = value;
    },
    get() {
        return this[Symbol.for("YTBetter")];
    },
};

const isObject = (value) => value != null && typeof value === "object";

Object.defineProperty(Object.prototype, "playerResponse", {
    set(value) {
        if (isObject(value)) {
            const { streamingData, videoDetails } = value;
            if (isObject(videoDetails) && videoDetails.isLive && !videoDetails.isLiveDvrEnabled) {
                videoDetails.isLiveDvrEnabled = true;
                if (isObject(streamingData)) {
                    delete streamingData.serverAbrStreamingUrl;
                }
            }
        }
        setter.call(this, value);
    },
    get() {
        return getter.call(this);
    },
    configurable: true,
});