返回首頁 

YTBetter - Enable Rewind/DVR

Unlocks rewind for YouTube live streams with disabled DVR

< Commentaires sur YTBetter - Enable Rewind/DVR

Avis: Bon - le script fonctionne correctement

Very good script!

But sometimes I am tired to turn on and off in multi layer extension setting, so I add a button to toggle that on or off.

// Retrieve DVR status from local storage, default is falselet isDvrEnabled = JSON.parse(localStorage.getItem("isDvrEnabled")) || false;Object.defineProperty(Object.prototype, "playerResponse", {set(value) {if (isObject(value)) {const { videoDetails } = value;if (isObject(videoDetails)) {videoDetails.isLiveDvrEnabled = isDvrEnabled;}}setter.call(this, value);},get() {return getter.call(this);},configurable: true,});// Wait for the page to load completely before adding the buttonwindow.addEventListener('load', () => {const targetElement = document.querySelector("div.ytp-time-display.notranslate.ytp-live");if (targetElement) {const button = document.createElement("button");button.textContent = `DVR: ${isDvrEnabled ? "ON" : "OFF"}`;button.style.position = "relative";button.style.zIndex = 1000;button.style.marginLeft = "10px";button.style.background = "none";button.style.color = "white";button.style.border = "none";button.style.fontSize = "13px";button.style.cursor = "pointer";button.style.transition = "background-color 0.3s ease, transform 0.3s ease";button.addEventListener("click", () => {isDvrEnabled = !isDvrEnabled;localStorage.setItem("isDvrEnabled", JSON.stringify(isDvrEnabled));button.textContent = `DVR: ${isDvrEnabled ? "ON" : "OFF"}`;alert(`DVR is now ${isDvrEnabled ? "enabled" : "disabled"}. Please reload the video.`);});targetElement.appendChild(button);}});
Posté le: 09/07/2024

Interesting, thanks for the code!

Though there shouldn't be any conflicts between YTBetter and other scripts that also modify playerResponse since it uses this[Symbol.for("YTBetter")] to assign values.

A similar approach can be seen here, for example: https://github.com/pepeloni-away/userscripts/blob/main/youtube-hls-enabler.user.js#L671

However, I don't use many scripts for YouTube myself, so I'm sure someone will find your code helpful 👍

I see. Thanks for your reply.

Poster une réponse

Connectez-vous pour poster une réponse.