Force Enable Copy/Paste/Select

Automatically enable copy, paste, and text selection on websites that block them.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Force Enable Copy/Paste/Select
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically enable copy, paste, and text selection on websites that block them.
// @author       (Based on bookmarklet)
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    "use strict";

    var t = ["copy", "cut", "paste", "selectstart", "contextmenu", "dragstart", "mousedown", "mouseup", "keydown", "keyup"],
        e = function(t) {
            return t.stopImmediatePropagation(), !0;
        };

    t.forEach(function(t) {
        document.addEventListener(t, e, !0);
    });

    document.oncopy = null;
    document.oncut = null;
    document.onpaste = null;
    document.onselectstart = null;
    document.oncontextmenu = null;
    document.ondragstart = null;
    document.onmousedown = null;

    var n = ["oncopy", "oncut", "onpaste", "onselectstart", "oncontextmenu", "ondragstart", "onmousedown"];

    function o(t) {
        n.forEach(function(e) {
            t.hasAttribute && t.hasAttribute(e) && t.removeAttribute(e);
        });
        t.hasAttribute && t.hasAttribute("unselectable") && t.removeAttribute("unselectable");
        t.style && (t.style.userSelect = "",
                    t.style.webkitUserSelect = "",
                    t.style.MozUserSelect = "",
                    t.style.msUserSelect = "",
                    t.style.webkitTouchCallout = "",
                    "none" === t.style.pointerEvents && (t.style.pointerEvents = ""));
        t.oncopy && (t.oncopy = null);
        t.oncut && (t.oncut = null);
        t.onpaste && (t.onpaste = null);
        t.onselectstart && (t.onselectstart = null);
        t.oncontextmenu && (t.oncontextmenu = null);
        t.ondragstart && (t.ondragstart = null);
    }

    for (var c = document.querySelectorAll("*"), r = 0; r < c.length; r++) o(c[r]);
    o(document.documentElement);
    o(document.body);

    var u = "__force_copy_style__";
    if (!document.getElementById(u)) {
        var l = document.createElement("style");
        l.id = u;
        l.textContent = [
            "*, *::before, *::after {",
            "  -webkit-user-select: auto !important;",
            "  -moz-user-select: auto !important;",
            "  -ms-user-select: auto !important;",
            "  user-select: auto !important;",
            "  -webkit-touch-callout: default !important;",
            "}",
            "html, body {",
            "  -webkit-user-select: auto !important;",
            "  user-select: auto !important;",
            "  pointer-events: auto !important;",
            "}"
        ].join("\n");
        (document.head || document.documentElement).appendChild(l);
    }

    try {
        for (var a = document.styleSheets, s = 0; s < a.length; s++)
            try {
                var i = a[s].cssRules || a[s].rules;
                if (!i) continue;
                for (var d = i.length - 1; d >= 0; d--) {
                    var m = i[d].cssText || "";
                    (/user-select\s*:\s*none/i.test(m) || /pointer-events\s*:\s*none/i.test(m)) && a[s].deleteRule(d);
                }
            } catch (t) {}
    } catch (t) {}

    try {
        if (!window.getSelection || -1 === window.getSelection.toString().indexOf("native")) {
            var p = document.createElement("iframe");
            p.style.display = "none";
            document.body.appendChild(p);
            p.contentWindow && p.contentWindow.getSelection && (window.getSelection = p.contentWindow.getSelection.bind(p.contentWindow));
            document.body.removeChild(p);
        }
    } catch (t) {}

    document.addEventListener("copy", function(t) {
        var e = window.getSelection();
        e && e.toString();
    }, !1);

    try {
        if (document.execCommand) {
            var y = document.execCommand.bind(document);
            document.execCommand = function(t) {
                return y.apply(document, arguments);
            };
        }
    } catch (t) {}

    new MutationObserver(function(t) {
        t.forEach(function(t) {
            t.addedNodes && t.addedNodes.forEach(function(t) {
                if (1 === t.nodeType) {
                    o(t);
                    for (var e = t.querySelectorAll ? t.querySelectorAll("*") : [], n = 0; n < e.length; n++) o(e[n]);
                }
            });
            "attributes" === t.type && 1 === t.target.nodeType && o(t.target);
        });
    }).observe(document.documentElement, {
        childList: !0,
        subtree: !0,
        attributes: !0,
        attributeFilter: n.concat(["style", "unselectable", "class"])
    });

    try {
        for (var f = document.querySelectorAll("iframe"), b = 0; b < f.length; b++)
            try {
                var h = f[b].contentDocument || f[b].contentWindow.document;
                if (h) {
                    t.forEach(function(t) {
                        h.addEventListener(t, e, !0);
                    });
                    h.oncopy = null;
                    h.oncut = null;
                    h.onpaste = null;
                    h.onselectstart = null;
                    h.oncontextmenu = null;
                    for (var v = h.querySelectorAll("*"), g = 0; g < v.length; g++) o(v[g]);
                    var w = h.createElement("style");
                    w.textContent = "* { -webkit-user-select: auto !important; user-select: auto !important; -webkit-touch-callout: default !important; }";
                    (h.head || h.documentElement).appendChild(w);
                }
            } catch (t) {}
    } catch (t) {}

    var x = document.createElement("div");
    x.textContent = "✅ Copy/Paste/Select enabled!";
    x.style.cssText = "position:fixed;top:8px;left:50%;transform:translateX(-50%);background:#222;color:#5fb950;padding:10px 24px;border-radius:8px;font:600 14px/1.4 system-ui,sans-serif;z-index:2147483647;box-shadow:0 4px 24px rgba(0,0,0,0.5);border:1px solid #5fb950;pointer-events:none;opacity:0;transition:opacity .3s ease;";
    document.body.appendChild(x);
    setTimeout(function() {
        x.style.opacity = "1";
    }, 50);
    setTimeout(function() {
        x.style.opacity = "0";
        setTimeout(function() {
            x.remove();
        }, 400);
    }, 2500);
})();