Force Copy/Paste Everywhere

Re-enable copy, paste, cut, text selection, and right-click on restrictive websites.

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!)

Advertisement:

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 لتثبيت هذا النمط.

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

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

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

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

Advertisement:

// ==UserScript==
// @name         Force Copy/Paste Everywhere
// @namespace    https://greasyfork.org/en/users/1573616-marito
// @version      1.0
// @description  Re-enable copy, paste, cut, text selection, and right-click on restrictive websites.
// @match        *://*/*
// @run-at       document-start
// @grant        none
// @license      Unlicense
// ==/UserScript==

(function () {
    'use strict';

    const stop = (e) => {
        e.stopImmediatePropagation();
    };

    [
        'copy',
        'cut',
        'paste',
        'contextmenu',
        'selectstart',
        'mousedown',
        'mouseup',
        'dragstart',
        'keydown',
        'keyup'
    ].forEach(event => {
        window.addEventListener(event, stop, true);
        document.addEventListener(event, stop, true);
    });

    const unlock = () => {
        document.querySelectorAll('*').forEach(el => {
            el.oncopy = null;
            el.oncut = null;
            el.onpaste = null;
            el.oncontextmenu = null;
            el.onselectstart = null;
            el.onmousedown = null;
            el.onmouseup = null;

            el.removeAttribute('oncopy');
            el.removeAttribute('oncut');
            el.removeAttribute('onpaste');
            el.removeAttribute('oncontextmenu');
            el.removeAttribute('onselectstart');

            el.style.userSelect = 'text';
            el.style.webkitUserSelect = 'text';
            el.style.MozUserSelect = 'text';
            el.style.msUserSelect = 'text';
        });
    };

    document.addEventListener('DOMContentLoaded', unlock);
    window.addEventListener('load', unlock);

    const observer = new MutationObserver(unlock);
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });
})();