Universal Bypass

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

目前為 2024-10-04 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Universal Bypass
// @namespace    https://github.com/x3ric
// @version      1.1
// @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';
    const settings = {
        rightClick: true, copyPaste: true, textSelection: true, dragDrop: false, keyboardShortcuts: false,
        pointerEvents: false, scrolling: true, unlockInputs: false, stopAutoPlay: false, enableVideoControls: false,
        removeOverlays: false, removeNoCopy: true, allowPasteInPassword: false, consoleBypass: false, debuggerBypass: false
    };

    const saveSettings = () => localStorage.setItem('universalBypassSettings', JSON.stringify(settings));
    const loadSettings = () => { const storedSettings = localStorage.getItem('universalBypassSettings'); if (storedSettings) Object.assign(settings, JSON.parse(storedSettings)); };

    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));
        };

        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);
        };

        if (settings.removeOverlays) document.querySelectorAll('.overlay, .modal, .popup, .lightbox, [role="dialog"]').forEach(el => el.style.display = 'none');
        if (settings.unlockInputs) document.querySelectorAll('input[disabled], textarea[disabled], select[disabled], input[readonly], textarea[readonly]').forEach(input => { input.disabled = false; input.readOnly = false; });
        if (settings.stopAutoPlay) document.querySelectorAll('video, audio').forEach(media => { media.autoplay = false; media.pause(); });
        if (settings.enableVideoControls) document.querySelectorAll('video').forEach(video => video.controls = true);
        if (settings.consoleBypass) console.clear = () => console.log("Console clear has been blocked.");
        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); } });
        }
        unblockEvents();
        removeBlockingAttributes();
    };

    const observeDOMChanges = () => { const observer = new MutationObserver(() => applyBypasses()); observer.observe(document.documentElement, { attributes: true, childList: true, subtree: true }); };

    const toggleSetting = (settingKey, settingName, menuCommandId) => {
        settings[settingKey] = !settings[settingKey];
        applyBypasses();
        saveSettings();
        GM_unregisterMenuCommand(menuCommandId);
        createMenu(settingKey, settingName);
    };

    const createMenu = (settingKey, settingName) => {
        const status = settings[settingKey] ? 'ON' : 'OFF';
        const menuCommandId = GM_registerMenuCommand(`${settingName} (${status})`, () => toggleSetting(settingKey, settingName, menuCommandId));
    };

    const init = () => {
        loadSettings();
        applyBypasses();
        observeDOMChanges();
        createMenu('rightClick', 'Right-Click');
        createMenu('copyPaste', 'Copy-Paste');
        createMenu('textSelection', 'Text Selection');
        createMenu('dragDrop', 'Drag-and-Drop');
        createMenu('keyboardShortcuts', 'Keyboard Shortcuts');
        createMenu('pointerEvents', 'Pointer Events');
        createMenu('scrolling', 'Scrolling');
        createMenu('unlockInputs', 'Unlock Inputs');
        createMenu('stopAutoPlay', 'Stop Auto-Play');
        createMenu('enableVideoControls', 'Enable Video Controls');
        createMenu('removeOverlays', 'Remove Overlays');
        createMenu('removeNoCopy', 'Remove No-Copy Classes');
        createMenu('allowPasteInPassword', 'Allow Paste in Password Fields');
        createMenu('consoleBypass', 'Console Bypass');
        createMenu('debuggerBypass', 'Debugger Bypass');
    };

    init();
})();