Nuclear Fullscreen Blocker

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

当前为 2025-05-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Nuclear Fullscreen Blocker
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.0
  5. // @description BLOCKS ALL fullscreen, including DRM video & browser-level tricks
  6. // @match *://*/*
  7. // @run-at document-start
  8. // @grant unsafeWindow
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // ===== [1] BLOCK ALL FULLSCREEN APIs =====
  15. const blockFullscreen = (element) => {
  16. const descriptors = {
  17. 'requestFullscreen': null,
  18. 'webkitRequestFullscreen': null,
  19. 'mozRequestFullScreen': null,
  20. 'msRequestFullscreen': null,
  21. 'exitFullscreen': null,
  22. 'webkitExitFullscreen': null,
  23. 'mozCancelFullScreen': null,
  24. 'msExitFullscreen': null,
  25. 'fullscreenEnabled': false,
  26. 'webkitFullscreenEnabled': false,
  27. 'mozFullScreenEnabled': false,
  28. 'msFullscreenEnabled': false
  29. };
  30.  
  31. for (const [prop, value] of Object.entries(descriptors)) {
  32. try {
  33. Object.defineProperty(element, prop, {
  34. value,
  35. writable: false,
  36. configurable: false
  37. });
  38. } catch (e) {}
  39. }
  40. };
  41.  
  42. // Block on document, HTML, and ALL elements
  43. blockFullscreen(document);
  44. blockFullscreen(HTMLElement.prototype);
  45. blockFullscreen(Element.prototype);
  46.  
  47. // ===== [2] MUTATIONOBSERVER (BLOCK NEW ELEMENTS) =====
  48. const observer = new MutationObserver((mutations) => {
  49. mutations.forEach((mutation) => {
  50. mutation.addedNodes.forEach((node) => {
  51. if (node.nodeType === Node.ELEMENT_NODE) {
  52. blockFullscreen(node);
  53. }
  54. });
  55. });
  56. });
  57. observer.observe(document, { childList: true, subtree: true });
  58.  
  59. // ===== [3] FORCE-EXIT FULLSCREEN EVERY SECOND =====
  60. setInterval(() => {
  61. if (document.fullscreenElement ||
  62. document.webkitFullscreenElement ||
  63. document.mozFullScreenElement ||
  64. document.msFullscreenElement) {
  65. document.exitFullscreen?.();
  66. document.webkitExitFullscreen?.();
  67. document.mozCancelFullScreen?.();
  68. document.msExitFullscreen?.();
  69. }
  70. }, 100);
  71.  
  72. // ===== [4] BLOCK F11, CTRL+ENTER, RIGHT-CLICK FULLSCREEN =====
  73. document.addEventListener('keydown', (e) => {
  74. if (e.key === 'F11' || (e.ctrlKey && e.key === 'Enter')) {
  75. e.preventDefault();
  76. e.stopImmediatePropagation();
  77. return false;
  78. }
  79. }, true);
  80.  
  81. document.addEventListener('contextmenu', (e) => {
  82. e.preventDefault();
  83. }, true);
  84.  
  85. // ===== [5] OVERRIDE VIDEO PLAYER FULLSCREEN BUTTONS =====
  86. document.addEventListener('DOMContentLoaded', () => {
  87. document.querySelectorAll('button, div, [role="button"]').forEach((btn) => {
  88. btn.addEventListener('click', (e) => {
  89. if (btn.innerText.includes('Fullscreen') ||
  90. btn.getAttribute('aria-label')?.includes('Fullscreen')) {
  91. e.stopImmediatePropagation();
  92. e.preventDefault();
  93. }
  94. }, true);
  95. });
  96. });
  97. })();