Guest User

Enable YouTube DVR

a guest
Mar 13th, 2023
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        YTBetter
  3. // @namespace   YTBetter
  4. // @match       https://*.youtube.com/*
  5. // @run-at      document-start
  6. // @grant       none
  7. // @version     2.0
  8. // @author      トワ…
  9. // @description Patches YouTube to bypass some limitations
  10. // ==/UserScript==
  11.  
  12. "use strict";
  13.  
  14. // Interop with "Simple YouTube Age Restriction Bypass"
  15. const {
  16.   get: getter,
  17.   set: setter,
  18. } = Object.getOwnPropertyDescriptor(Object.prototype, "playerResponse") ?? {
  19.   set(value) {
  20.     this[Symbol.for("YTBetter")] = value;
  21.   },
  22.   get() {
  23.     return this[Symbol.for("YTBetter")];
  24.   },
  25. };
  26.  
  27. const isObject = (value) => value != null && typeof value === "object";
  28.  
  29. Object.defineProperty(Object.prototype, "playerResponse", {
  30.   set(value) {
  31.     if (isObject(value)) {
  32.       const { videoDetails } = value;
  33.       if (isObject(videoDetails)) {
  34.         videoDetails.isLiveDvrEnabled = true;
  35.       }
  36.     }
  37.     setter.call(this, value);
  38.   },
  39.   get() {
  40.     return getter.call(this);
  41.   },
  42.   configurable: true,
  43. });
Add Comment
Please, Sign In to add comment