Universal Bypass

Bypass common web restrictions: right-click, copy-paste, text selection, drag/drop, scrolling, video controls, console, debugger, and more.

当前为 2024-10-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Universal Bypass
// @namespace    https://github.com/x3ric
// @version      1.0
// @description  Bypass common web restrictions: right-click, copy-paste, text selection, drag/drop, scrolling, video controls, console, debugger, and more.
// @author       x3ric
// @license      MIT
// @match        *://*/*
// @run-at       document-start
// @grant        unsafeWindow
// @grant        GM_registerMenuCommand
// ==/UserScript==
(function () {
    'use strict';

    // Bypass settings, less intrusive features disabled by default
    const settings = {
        rightClick: true,             // Enable right-click by default
        copyPaste: true,              // Enable copy/paste by default
        textSelection: true,          // Enable text selection by default
        dragDrop: false,              // Disabled by default to avoid drag/drop interference
        keyboardShortcuts: false,     // Disabled by default to prevent keyboard shortcut issues
        pointerEvents: false,         // Disabled by default, avoid pointer event conflicts
        scrolling: true,              // Enable scrolling by default
        unlockInputs: false,          // Disabled by default to avoid form issues
        stopAutoPlay: false,          // Disabled by default, less intrusive
        enableVideoControls: false,   // Disabled by default, less intrusive
        removeOverlays: false,        // Disabled by default, can be disruptive on some sites
        removeNoCopy: true,           // Enable removal of "no-copy" restrictions by default
        allowPasteInPassword: false,  // Disabled by default, avoid input interference
        consoleBypass: false,         // Disabled by default, activate when needed
        debuggerBypass: false         // Disabled by default, activate when needed
    };

    // Apply essential bypasses
    const applyBypasses = () => {
        const unblockEvents = () => {
            const eventsToUnblock = [];
            if (settings.rightClick) eventsToUnblock.push('contextmenu');
            if (settings.copyPaste) eventsToUnblock.push('copy', 'paste', 'cut');
            if (settings.textSelection) eventsToUnblock.push('selectstart');
            if (settings.dragDrop) eventsToUnblock.push('dragstart', 'drop');
            if (settings.keyboardShortcuts) eventsToUnblock.push('keydown', 'keypress', 'keyup');
            if (settings.pointerEvents) eventsToUnblock.push('pointerdown', 'pointerup', 'mousedown', 'mouseup', 'click');
            if (settings.scrolling) eventsToUnblock.push('wheel', 'touchmove', 'scroll');

            eventsToUnblock.forEach(eventType => {
                document.addEventListener(eventType, e => e.stopPropagation(), true);
            });
        };

        // Remove blocking attributes
        const removeBlockingAttributes = () => {
            const attrsToRemove = ['oncontextmenu', 'oncopy', 'onpaste', 'oncut', 'onselectstart', 'ondragstart', 'ondrop', 'onkeydown', 'onkeypress', 'onkeyup', 'onpointerdown', 'onpointerup', 'onclick', 'onscroll'];
            attrsToRemove.forEach(attr => {
                document.querySelectorAll(`[${attr}]`).forEach(el => el.removeAttribute(attr));
            });

            if (settings.removeNoCopy) {
                document.querySelectorAll('[class*="no-copy"], [class*="unselectable"]').forEach(el => {
                    el.classList.remove('no-copy', 'unselectable');
                });
            }

            if (settings.allowPasteInPassword) {
                document.querySelectorAll('input[type="password"]').forEach(input => {
                    input.onpaste = null;
                });
            }
        };

        // Remove overlays and modals
        if (settings.removeOverlays) {
            document.querySelectorAll('.overlay, .modal, .popup, .lightbox, [role="dialog"]').forEach(el => {
                el.style.display = 'none';
            });
        }

        // Unlock disabled or readonly inputs
        if (settings.unlockInputs) {
            document.querySelectorAll('input[disabled], textarea[disabled], select[disabled], input[readonly], textarea[readonly]').forEach(input => {
                input.disabled = false;
                input.readOnly = false;
            });
        }

        // Stop auto-playing media
        if (settings.stopAutoPlay) {
            document.querySelectorAll('video, audio').forEach(media => {
                media.autoplay = false;
                media.pause();
            });
        }

        // Enable video controls
        if (settings.enableVideoControls) {
            document.querySelectorAll('video').forEach(video => {
                video.controls = true;
            });
        }

        // Console Bypass (prevents websites from clearing the console)
        if (settings.consoleBypass) {
            console.clear = () => console.log("Console clear has been blocked.");
        }

        // Debugger Bypass (injects `debugger` into eval and Function)
        if (settings.debuggerBypass) {
            const injectDebugger = `debugger;`;
            unsafeWindow.eval = new Proxy(unsafeWindow.eval, {
                apply: (target, thisArg, args) => {
                    if (typeof args[0] === 'string') {
                        args[0] = `${injectDebugger} ${args[0]}`;
                    }
                    return Reflect.apply(target, thisArg, args);
                }
            });

            unsafeWindow.Function = new Proxy(unsafeWindow.Function, {
                construct: (target, args) => {
                    if (typeof args[args.length - 1] === 'string') {
                        args[args.length - 1] = `${injectDebugger} ${args[args.length - 1]}`;
                    }
                    return Reflect.construct(target, args);
                }
            });
        }

        // Re-apply unblocking functions
        unblockEvents();
        removeBlockingAttributes();
    };

    // Observe DOM changes to re-apply bypasses
    const observeDOMChanges = () => {
        const observer = new MutationObserver(() => {
            applyBypasses();
        });
        observer.observe(document.documentElement, { attributes: true, childList: true, subtree: true });
    };

    // Initialize script
    const init = () => {
        applyBypasses();
        observeDOMChanges();
    };

    // Helper function for toggling settings
    const toggleSetting = (settingKey, settingName) => {
        settings[settingKey] = !settings[settingKey];
        applyBypasses();
        alert(`${settingName} has been ${settings[settingKey] ? 'enabled' : 'disabled'}.`);
    };

    // Register menu commands
    GM_registerMenuCommand('Toggle Right-Click', () => toggleSetting('rightClick', 'Right-Click'));
    GM_registerMenuCommand('Toggle Copy-Paste', () => toggleSetting('copyPaste', 'Copy-Paste'));
    GM_registerMenuCommand('Toggle Text Selection', () => toggleSetting('textSelection', 'Text Selection'));
    GM_registerMenuCommand('Toggle Drag-and-Drop', () => toggleSetting('dragDrop', 'Drag-and-Drop'));
    GM_registerMenuCommand('Toggle Keyboard Shortcuts', () => toggleSetting('keyboardShortcuts', 'Keyboard Shortcuts'));
    GM_registerMenuCommand('Toggle Pointer Events', () => toggleSetting('pointerEvents', 'Pointer Events'));
    GM_registerMenuCommand('Toggle Scrolling', () => toggleSetting('scrolling', 'Scrolling'));
    GM_registerMenuCommand('Toggle Unlock Inputs', () => toggleSetting('unlockInputs', 'Unlock Inputs'));
    GM_registerMenuCommand('Toggle Stop Auto-Play', () => toggleSetting('stopAutoPlay', 'Stop Auto-Play'));
    GM_registerMenuCommand('Toggle Enable Video Controls', () => toggleSetting('enableVideoControls', 'Enable Video Controls'));
    GM_registerMenuCommand('Toggle Remove Overlays', () => toggleSetting('removeOverlays', 'Remove Overlays'));
    GM_registerMenuCommand('Toggle Remove No-Copy Classes', () => toggleSetting('removeNoCopy', 'Remove No-Copy Classes'));
    GM_registerMenuCommand('Toggle Allow Paste in Password Fields', () => toggleSetting('allowPasteInPassword', 'Allow Paste in Password Fields'));
    GM_registerMenuCommand('Toggle Console Bypass', () => toggleSetting('consoleBypass', 'Console Bypass'));
    GM_registerMenuCommand('Toggle Debugger Bypass', () => toggleSetting('debuggerBypass', 'Debugger Bypass'));

    // Initialize the script
    init();

})();