Greasy Fork

Greasy Fork is available in English.

解除网页复制限制

在Chrome下实现全面的解除网页复制限制

当前为 2020-05-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            解除网页复制限制
// @name:en         Copy Enabler
// @namespace       https://tautcony.xyz/
// @license         GPL version 3
// @encoding        utf-8
// @version         0.3
// @description     在Chrome下实现全面的解除网页复制限制
// @description:en  Disable all copy restrictions in Chrome
// @date            2020/05/18
// @modified        2020/05/18
// @author          TautCony
// @include         *
// @grant           none
// ==/UserScript==


function copyEnabler(curr_window) {
    const eventArr = ['contextmenu', 'dragstart', 'mouseup', 'mousedown', 'mousemove', 'copy', 'cut', 'beforecopy', 'selectstart', 'select', 'keydown'];
    function runScript(curr_window) {
        let _jq_ = curr_window.jQuery || curr_window.$j;
        if (typeof _jq_ !== "undefined" && _jq_.toString().includes("[Command Line API]")) {
            _jq_ = undefined;
        }
        if (typeof _jq_ === "undefined") {
            console.warn("No jQuery found");
        }
        const unbind = function (ele) {
            let listeners = {};
            if (typeof getEventListeners === "function") {
                listeners = getEventListeners(ele);
                /* if (Object.keys(listeners).length > 0) console.log(listeners); */
            }
            for (const evt of eventArr) {
                ele['on' + evt] = null;
                if (_jq_) {
                    const jq_ele = _jq_(ele);
                    if (jq_ele.off) jq_ele.off(evt); else if (jq_ele.unbind) jq_ele.unbind(evt);
                }
                if (ele.style && ele.style.userSelect === 'none') ele.style.userSelect = 'text';
                if (listeners[evt]) {
                    for (const handler of listeners[evt]) {
                        ele.removeEventListener(evt, handler.listener, handler.useCapture);
                    }
                }
                try {
                    if (/frame/i.test(ele.tagName)) {
                        if (ele.src.startsWith(curr_window.location.origin)) {
                            runScript(ele.contentWindow);
                        }
                    }
                } catch (err) {
                    console.error(err);
                }
            }
        };
        [curr_window, curr_window.document].forEach(unbind);
        Array.from(curr_window.document.all).filter(ele => ele.nodeType === Node.ELEMENT_NODE).forEach(unbind);
        (function utanet() {
            const img = document.querySelector('#flash_area>img');
            if (img && img.style) img.style.display = 'none';
        })();
    }
    runScript(curr_window);
}

window.copyEnabler = () => copyEnabler(window);

document.addEventListener('keydown', (e) => {
    if (e.keyCode = 123) {
        const max_id = setTimeout(()=>{});
        for (let i = 0; i < max_id; ++i) {
            try {
                clearInterval(i);
                clearTimeout(i);
            } catch (ignore) {
            }
        }
    }
}, false);