Greasy Fork

Greasy Fork is available in English.

网页右键与复制限制解除(轻量版)

轻量级的网页限制解除脚本,只解除右键和复制限制,提供更好的兼容性

当前为 2025-03-06 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @namespace         http://greasyfork.icu/zh-CN/users/106222-qxin-i
 
// @name              网页右键与复制限制解除(轻量版)
// @name:en           Remove web right-click and copy limits(Lite)
// @name:zh           网页右键与复制限制解除(轻量版)
 
// @description       轻量级的网页限制解除脚本,只解除右键和复制限制,提供更好的兼容性
// @description:en    A lightweight script to remove right-click and copy restrictions with better compatibility
// @description:zh    轻量级的网页限制解除脚本,只解除右键和复制限制,提供更好的兼容性
 
// @author            Cat73 & iqxin(修改) & 小天队长(精简优化)
 
// @version           1.0.0
// @license           LGPLv3
 
// @match             *://*/*
// @exclude        *www.bilibili.com/video*
// @exclude        *www.bilibili.com/v*
// @exclude        *www.bilibili.com/s/*
// @exclude        *www.bilibili.com/bangumi*
// @exclude        https://www.bilibili.com/medialist/play/*
// @exclude        *www.youtube.com/watch*
// @exclude        *www.panda.tv*
// @exclude        *www.github.com*
// @exclude        https://lanhuapp.com/*
// @exclude        https://www.douyu.com/*
// @exclude        https://www.zhihu.com/signin?*
// @exclude        https://tieba.baidu.com/*
// @exclude        https://v.qq.com/*
// @exclude        *.taobao.com/*
// @exclude        *tmall.com*
// @exclude        *signin*
 
// @grant           GM_addStyle
// @run-at          document-start
// ==/UserScript==
 
(function() {
    'use strict';
    
    // 添加允许选择文本的CSS
    GM_addStyle('html, body {-webkit-user-select:text!important; -moz-user-select:text!important; user-select:text!important;} ::selection {color:#fff; background:#3390FF!important;}');
    
    // 核心功能: 只处理右键和复制事件
    function enableRightClickAndCopy() {
        // 移除右键菜单限制
        document.addEventListener('contextmenu', function(e) {
            e.stopPropagation();
            return true;
        }, true);
        
        // 移除复制限制
        document.addEventListener('copy', function(e) {
            e.stopPropagation();
            return true;
        }, true);
        
        // 移除选择限制
        document.addEventListener('selectstart', function(e) {
            e.stopPropagation();
            return true;
        }, true);
        
        // 清除可能存在的限制属性
        function clearRestrictions() {
            document.onselectstart = null;
            document.oncontextmenu = null;
            document.oncopy = null;
            document.onmousedown = null;
            document.onmouseup = null;
        }
        
        // 定期清除限制
        setInterval(clearRestrictions, 1000);
        window.addEventListener('load', clearRestrictions, true);
    }
    
    // 启动功能
    enableRightClickAndCopy();
})();