Skip to content

Instantly share code, notes, and snippets.

@ian4blancasa
Created October 14, 2024 20:03
Show Gist options
  • Save ian4blancasa/84ffafc22e9b5b2934e3ba725dd749a7 to your computer and use it in GitHub Desktop.
Save ian4blancasa/84ffafc22e9b5b2934e3ba725dd749a7 to your computer and use it in GitHub Desktop.
TamperMonkey Script - Youtube always In teather mode.
// ==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