您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
恢复被网站禁用的复制功能,例如飞书、钉钉、百度文库等。支持右键菜单复制,支持ctrl+c、command+c复制
// ==UserScript== // @name 为什么不让我复制?(解除如飞书、钉钉、百度文库等的复制限制) // @namespace http://tampermonkey.net/ // @version 1.1 // @description 恢复被网站禁用的复制功能,例如飞书、钉钉、百度文库等。支持右键菜单复制,支持ctrl+c、command+c复制 // @author HuSheng // @match *://*/* // @grant none // @run-at document-start // @license GPL-2.0-only // ==/UserScript== (function() { 'use strict'; // 原始事件 const originalAddEventListener = EventTarget.prototype.addEventListener; const originalPreventDefault = Event.prototype.preventDefault; const originalStopPropagation = Event.prototype.stopPropagation; const originalStopImmediatePropagation = Event.prototype.stopImmediatePropagation; // 覆盖addEventListener EventTarget.prototype.addEventListener = function(type, listener, options) { if (type === 'copy') { return; } // 拦截Ctrl+C、Command+C if (type === 'keydown') { const listenerStr = listener.toString(); if (listenerStr.includes('keyCode:67') || listenerStr.includes('keyCode===67') || listenerStr.includes('key:"c"') || (listenerStr.includes('ctrlKey') && listenerStr.includes('67')) || (listenerStr.includes('metaKey') && listenerStr.includes('67'))) { return; } } originalAddEventListener.call(this, type, listener, options); }; // 覆盖事件方法 Event.prototype.preventDefault = function() { if (this.type === 'copy' || (this.type === 'keydown' && this.keyCode === 67 && (this.ctrlKey || this.metaKey))) { return; } originalPreventDefault.call(this); }; Event.prototype.stopPropagation = function() { if (this.type === 'copy' || (this.type === 'keydown' && this.keyCode === 67 && (this.ctrlKey || this.metaKey))) { return; } originalStopPropagation.call(this); }; Event.prototype.stopImmediatePropagation = function() { if (this.type === 'copy' || (this.type === 'keydown' && this.keyCode === 67 && (this.ctrlKey || this.metaKey))) { return; } originalStopImmediatePropagation.call(this); }; // 添加右键菜单复制支持 document.addEventListener('contextmenu', function(e) { e.stopImmediatePropagation(); }, true); })();