Enable Copy Paste and Right Click

This script forcefully removes all JavaScript restrictions to enable text selection, copy-paste (Ctrl+C, Ctrl+V), and right-click (context menu) on restrictive websites.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Enable Copy Paste and Right Click
// @namespace    https://greasyfork.org/en/users/1461725-scriptninja
// @version      1.0.0
// @description  This script forcefully removes all JavaScript restrictions to enable text selection, copy-paste (Ctrl+C, Ctrl+V), and right-click (context menu) on restrictive websites.
// @author       ScriptNinja
// @license      MIT
// @match        *://*/*
// @icon         https://www.google.com/s2/favicons?domain=greasyfork.org
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // 1. Function to clear event listeners and attributes
    function clearEventListeners() {
        // Clear common event handlers on document
        document.oncontextmenu = null;
        document.oncopy = null;
        document.oncut = null;
        document.onpaste = null;
        document.onselectstart = null;
        document.onkeydown = null;

        // Clear event handlers on body (if body exists)
        if (document.body) {
            document.body.oncontextmenu = null;
            document.body.oncopy = null;
            document.body.oncut = null;
            document.body.onpaste = null;
            document.body.onselectstart = null;
            document.body.removeAttribute('oncopy');
            document.body.removeAttribute('onselectstart');
            document.body.removeAttribute('oncontextmenu');
        }

        // 2. Force default action (allow) on events during the Capturing Phase
        var allowAction = function(e){
            e.stopImmediatePropagation();
            return true;
        };

        // Add event listeners to override restrictions
        document.addEventListener('contextmenu', allowAction, true);
        document.addEventListener('copy', allowAction, true);
        document.addEventListener('paste', allowAction, true);
        document.addEventListener('cut', allowAction, true);
        document.addEventListener('selectstart', allowAction, true);
        document.addEventListener('keydown', allowAction, true);

        // 3. Override CSS property `user-select: none` using !important
        var style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = '* { -webkit-user-select: text !important; -moz-user-select: text !important; -ms-user-select: text !important; user-select: text !important; }';
        if (document.head) {
            document.head.appendChild(style);
        }
    }

    // Run immediately before the page loads any other scripts (@run-at document-start)
    clearEventListeners();

    // Run again after the page loads and multiple times with a delay to catch late-loading scripts
    window.addEventListener('load', clearEventListeners);
    setTimeout(clearEventListeners, 1000);
    setTimeout(clearEventListeners, 3000);
    setTimeout(clearEventListeners, 5000);
})();