Created
October 14, 2024 20:03
-
-
Save ian4blancasa/84ffafc22e9b5b2934e3ba725dd749a7 to your computer and use it in GitHub Desktop.
TamperMonkey Script - Youtube always In teather mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube Auto Theater Mode | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Forces YouTube to always use theater mode | |
// @author Ian_Blancasa | |
// @match *://www.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Function to enable theater mode | |
function enableTheaterMode() { | |
const theaterModeButton = document.querySelector('.ytp-size-button'); | |
const isTheaterMode = document.querySelector('ytd-watch-flexy[theater]'); | |
// If theater mode is not enabled, click the button to enable it | |
if (!isTheaterMode && theaterModeButton) { | |
theaterModeButton.click(); | |
} | |
} | |
// Create a MutationObserver to observe changes in the page (e.g., navigation) | |
const observer = new MutationObserver((mutations) => { | |
enableTheaterMode(); | |
}); | |
// Start observing the body for changes | |
observer.observe(document.body, { childList: true, subtree: true }); | |
// Run the function immediately when the script loads | |
enableTheaterMode(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment