Greasy Fork

Greasy Fork is available in English.

FuckNoCopy

解除所有网站的复制限制

当前为 2025-05-21 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         FuckNoCopy
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  解除所有网站的复制限制
// @author       [email protected]
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const copyListeners = [];

    // 保存原始的 addEventListener 和 removeEventListener 方法
    const originalAddEventListener = EventTarget.prototype.addEventListener;
    const originalRemoveEventListener = EventTarget.prototype.removeEventListener;

    // 覆盖 addEventListener 方法
    EventTarget.prototype.addEventListener = function(type, listener, options) {
        // 如果是 copy 事件,记录监听器
        if (type === 'copy') {
            copyListeners.push({ target: this, listener, options });
        }
        // 调用原始的 addEventListener 方法
        originalAddEventListener.call(this, type, listener, options);
    };

    // 覆盖 removeEventListener 方法
    EventTarget.prototype.removeEventListener = function(type, listener, options) {
        // 如果是 copy 事件,从记录中移除监听器
        if (type === 'copy') {
            const index = copyListeners.findIndex(item => item.target === this && item.listener === listener);
            if (index !== -1) {
                copyListeners.splice(index, 1);
            }
        }
        // 调用原始的 removeEventListener 方法
        originalRemoveEventListener.call(this, type, listener, options);
    };

    // 确保在文档加载完成后移除所有 copy 事件监听器
    document.addEventListener('DOMContentLoaded', function() {
        // 移除所有记录的 copy 事件监听器
        copyListeners.forEach(listener => {
            listener.target.removeEventListener('copy', listener.listener, listener.options);
        });
        // 清空记录
        copyListeners.length = 0;
    });
})();