Force Copy/Paste Everywhere

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला 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
    });
})();