以下代码为油猴脚本,需要先在浏览器中安装油猴插件
https://www.tampermonkey.net/
然后点击新建脚本复制粘贴以下代码即可
// ==UserScript==
// @name CP51100
// @namespace http://nopj.cn
// @version 2025-05-27
// @description 解除51100复制粘贴限制
// @author Chaos
// @match https://scdxskgkh5.51100.net/
// @icon https://www.google.com/s2/favicons?sz=64&domain=51100.net
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('copy', function(e) {
e.stopImmediatePropagation();
}, true);
document.addEventListener('cut', function(e) {
e.stopImmediatePropagation();
}, true);
document.addEventListener('paste', function(e) {
e.stopImmediatePropagation();
}, true);
const observer = new MutationObserver((mutationsList, observer) => {
for (const mutation of mutationsList) {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1) {
node.querySelectorAll('*').forEach(el => {
el.oncopy = null;
el.oncut = null;
el.onpaste = null;
});
if (node.oncopy) node.oncopy = null;
if (node.oncut) node.oncut = null;
if (node.onpaste) node.onpaste = null;
}
});
}
}
});
observer.observe(document.body, { childList: true, subtree: true });
window.addEventListener('DOMContentLoaded', () => {
const events = ['copy', 'cut', 'paste'];
events.forEach(event => {
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, listener, options) {
if (type === event) {
console.log(`Tampermonkey: Preventing '${type}' event listener from being added.`);
return;
}
originalAddEventListener.call(this, type, listener, options);
};
const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
EventTarget.prototype.removeEventListener = function(type, listener, options) {
if (type === event) {
console.log(`Tampermonkey: Attempting to remove '${type}' event listener.`);
}
originalRemoveEventListener.call(this, type, listener, options);
};
document.removeEventListener(event, preventDefaultHandler, true);
document.removeEventListener(event, preventDefaultHandler, false);
document.addEventListener(event, function(e) {
e.stopImmediatePropagation();
}, true);
});
Object.defineProperty(HTMLInputElement.prototype, 'onpaste', {
get: function() { return function() {}; },
set: function() {}
});
Object.defineProperty(HTMLTextAreaElement.prototype, 'onpaste', {
get: function() { return function() {}; },
set: function() {}
});
Object.defineProperty(HTMLElement.prototype, 'oncopy', {
get: function() { return function() {}; },
set: function() {}
});
Object.defineProperty(HTMLElement.prototype, 'oncut', {
get: function() { return function() {}; },
set: function() {}
});
Object.defineProperty(HTMLElement.prototype, 'onpaste', {
get: function() { return function() {}; },
set: function() {}
});
document.addEventListener('copy', (e) => { e.stopImmediatePropagation(); }, true);
document.addEventListener('cut', (e) => { e.stopImmediatePropagation(); }, true);
document.addEventListener('paste', (e) => { e.stopImmediatePropagation(); }, true);
document.body.addEventListener('copy', (e) => { e.stopImmediatePropagation(); }, true);
document.body.addEventListener('cut', (e) => { e.stopImmediatePropagation(); }, true);
document.body.addEventListener('paste', (e) => { e.stopImmediatePropagation(); }, true);
Promise.resolve().then(() => {
document.querySelectorAll('*').forEach(el => {
['copy', 'cut', 'paste'].forEach(event => {
const handlers = Array.from(getEventListeners(el, event));
handlers.forEach(handler => el.removeEventListener(event, handler.listener, handler.capture));
});
});
});
});
function getEventListeners(element, type) {
if (typeof window.getEventListeners === 'function') {
return window.getEventListeners(element, type);
} else {
console.warn("getEventListeners is not available. Cannot enumerate event listeners directly.");
return [];
}
}
})();