您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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);
- });
- });
- })();