Universal Bypass

Bypass common web restrictions: right-click, copy-paste, text selection, console, debugger, and more.

  1. // ==UserScript==
  2. // @name Universal Bypass
  3. // @namespace https://github.com/x3ric
  4. // @version 1.54
  5. // @description Bypass common web restrictions: right-click, copy-paste, text selection, console, debugger, and more.
  6. // @author x3ric
  7. // @license MIT
  8. // @match *://*/*
  9. // @run-at document-start
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_registerMenuCommand
  13. // @grant GM_unregisterMenuCommand
  14. // @grant GM_notification
  15. // @grant unsafeWindow
  16. // ==/UserScript==
  17.  
  18. (function () {
  19. 'use strict';
  20.  
  21. const settings = GM_getValue('universal_bypass_options', {
  22. rightClick: false,
  23. copyPaste: true,
  24. textSelection: true,
  25. consoleBypass: false,
  26. debuggerBypass: false
  27. });
  28.  
  29. const saveSettings = () => GM_setValue('universal_bypass_options', settings);
  30.  
  31. const applyBypasses = () => {
  32. // Right-click bypass
  33. if (settings.rightClick) {
  34. window.addEventListener('contextmenu', e => e.stopImmediatePropagation(), { capture: true });
  35. }
  36.  
  37. // Copy/Paste/Cut bypass
  38. if (settings.copyPaste) {
  39. ['copy', 'paste', 'cut'].forEach(ev => {
  40. document.addEventListener(ev, e => { // Check if the event originates from a restricted element
  41. const target = e.target;
  42. const restrictedElements = ['INPUT', 'TEXTAREA', 'DIV'];
  43. if (restrictedElements.includes(target.tagName) && target.isContentEditable) {
  44. e.stopImmediatePropagation();
  45. }
  46. }, { capture: true });
  47. });
  48. }
  49.  
  50. // Text selection bypass with minimal DOM manipulation
  51. if (settings.textSelection) {
  52. if (!document.getElementById('universalBypass-style')) {
  53. const style = document.createElement('style');
  54. style.id = 'universalBypass-style';
  55. style.textContent = `
  56. * { user-select: text !important; }
  57. ::selection { background: #b3d4fc; color: #000; }
  58. `;
  59. document.head.appendChild(style);
  60. }
  61. }
  62.  
  63. // Console bypass
  64. if (settings.consoleBypass) {
  65. const noop = () => {};
  66. ['clear', 'debug', 'log', 'warn', 'error'].forEach(method => {
  67. console[method] = noop;
  68. });
  69. }
  70.  
  71. // Debugger bypass
  72. if (settings.debuggerBypass) {
  73. unsafeWindow.eval = new Proxy(unsafeWindow.eval, {
  74. apply: (target, thisArg, args) => {
  75. args[0] = args[0].replace(/debugger/g, ''); // Remove debugger statements
  76. return Reflect.apply(target, thisArg, args);
  77. }
  78. });
  79. }
  80. };
  81.  
  82. // Handle setting toggling
  83. const toggleSetting = key => {
  84. settings[key] = !settings[key];
  85. saveSettings();
  86. applyBypasses();
  87. GM_notification({
  88. text: `${key.replace(/([A-Z])/g, ' $1').trim()} is now ${settings[key] ? 'ON' : 'OFF'}`,
  89. title: 'Universal Bypass',
  90. timeout: 3000
  91. });
  92. updateMenuCommand(key);
  93. };
  94.  
  95. // Update the GM menu
  96. const menuCommands = {};
  97. const updateMenuCommand = (key) => {
  98. if (menuCommands[key]) GM_unregisterMenuCommand(menuCommands[key]);
  99. menuCommands[key] = GM_registerMenuCommand(
  100. `${key.replace(/([A-Z])/g, ' $1').trim()} (${settings[key] ? 'ON' : 'OFF'})`,
  101. () => toggleSetting(key)
  102. );
  103. };
  104.  
  105. // Set up menu and apply initial bypasses
  106. Object.keys(settings).forEach(updateMenuCommand);
  107. applyBypasses();
  108.  
  109. // Minimal DOM monitoring (trigger bypasses only when relevant changes occur)
  110. const observer = new MutationObserver(mutations => {
  111. for (const mutation of mutations) {
  112. if (mutation.type === 'childList') {
  113. applyBypasses();
  114. }
  115. }
  116. });
  117.  
  118. observer.observe(document.documentElement, { childList: true, subtree: true });
  119.  
  120. // Reapply bypasses on page navigation events
  121. ['load', 'popstate', 'pushstate', 'replacestate'].forEach(event =>
  122. window.addEventListener(event, applyBypasses, true)
  123. );
  124. })();