YouTubeNeverSleeps

Disable/Enable video breaks.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         YouTubeNeverSleeps
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Disable/Enable video breaks.
// @author       Claude Opus 4.6
// @license MIT
// @match        https://www.youtube.com/*
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

(function() {
    'use strict';

    let noPauseInterval = null;
    let menuCommandId = null;

    function startNoPause() {
        if (noPauseInterval) return;
        noPauseInterval = setInterval(function() {
            // click No Thanks, Yes
            document.querySelectorAll('[aria-label="No thanks"], [aria-label="Yes"]').forEach(function(element) {
                if (element.offsetParent != null) element.click();
            });
            // press play if paused
            const video = document.querySelector('video');
            if (video && video.paused) {
                video.play();
            }
        }, 1000);
        console.log("NoPause: ON");
    }

    function stopNoPause() {
        if (noPauseInterval) {
            clearInterval(noPauseInterval);
            noPauseInterval = null;
        }
        console.log("NoPause: OFF");
    }

    function updateMenu() {
        if (menuCommandId !== null) {
            GM_unregisterMenuCommand(menuCommandId);
        }

        const enabled = GM_getValue('noPauseEnabled', true);

        if (enabled) {
            menuCommandId = GM_registerMenuCommand('⏸ Turn OFF noPause', function() {
                GM_setValue('noPauseEnabled', false);
                stopNoPause();
                updateMenu();
            });
        } else {
            menuCommandId = GM_registerMenuCommand('▶ Turn ON noPause', function() {
                GM_setValue('noPauseEnabled', true);
                startNoPause();
                updateMenu();
            });
        }
    }

    const enabled = GM_getValue('noPauseEnabled', true);
    if (enabled) {
        startNoPause();
    }
    updateMenu();

})();