Nuclear Fullscreen Blocker

BLOCKS ALL fullscreen, including DRM video & browser-level tricks

// ==UserScript==
// @name         Nuclear Fullscreen Blocker
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  BLOCKS ALL fullscreen, including DRM video & browser-level tricks
// @match        *://*/*
// @run-at       document-start
// @grant        unsafeWindow
// ==/UserScript==

(function() {
    'use strict';

    // ===== [1] BLOCK ALL FULLSCREEN APIs =====
    const blockFullscreen = (element) => {
        const descriptors = {
            'requestFullscreen': null,
            'webkitRequestFullscreen': null,
            'mozRequestFullScreen': null,
            'msRequestFullscreen': null,
            'exitFullscreen': null,
            'webkitExitFullscreen': null,
            'mozCancelFullScreen': null,
            'msExitFullscreen': null,
            'fullscreenEnabled': false,
            'webkitFullscreenEnabled': false,
            'mozFullScreenEnabled': false,
            'msFullscreenEnabled': false
        };

        for (const [prop, value] of Object.entries(descriptors)) {
            try {
                Object.defineProperty(element, prop, { 
                    value, 
                    writable: false, 
                    configurable: false 
                });
            } catch (e) {}
        }
    };

    // Block on document, HTML, and ALL elements
    blockFullscreen(document);
    blockFullscreen(HTMLElement.prototype);
    blockFullscreen(Element.prototype);

    // ===== [2] MUTATIONOBSERVER (BLOCK NEW ELEMENTS) =====
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.nodeType === Node.ELEMENT_NODE) {
                    blockFullscreen(node);
                }
            });
        });
    });
    observer.observe(document, { childList: true, subtree: true });

    // ===== [3] FORCE-EXIT FULLSCREEN EVERY SECOND =====
    setInterval(() => {
        if (document.fullscreenElement || 
            document.webkitFullscreenElement || 
            document.mozFullScreenElement || 
            document.msFullscreenElement) {
            document.exitFullscreen?.();
            document.webkitExitFullscreen?.();
            document.mozCancelFullScreen?.();
            document.msExitFullscreen?.();
        }
    }, 100);

    // ===== [4] BLOCK F11, CTRL+ENTER, RIGHT-CLICK FULLSCREEN =====
    document.addEventListener('keydown', (e) => {
        if (e.key === 'F11' || (e.ctrlKey && e.key === 'Enter')) {
            e.preventDefault();
            e.stopImmediatePropagation();
            return false;
        }
    }, true);

    document.addEventListener('contextmenu', (e) => {
        e.preventDefault();
    }, true);

    // ===== [5] OVERRIDE VIDEO PLAYER FULLSCREEN BUTTONS =====
    document.addEventListener('DOMContentLoaded', () => {
        document.querySelectorAll('button, div, [role="button"]').forEach((btn) => {
            btn.addEventListener('click', (e) => {
                if (btn.innerText.includes('Fullscreen') || 
                    btn.getAttribute('aria-label')?.includes('Fullscreen')) {
                    e.stopImmediatePropagation();
                    e.preventDefault();
                }
            }, true);
        });
    });
})();