Loading... # 批改网去除复制粘贴JS脚本 使用要求:浏览器安装了油猴扩展 ## 功能描述 批改网作文禁止粘贴,导致无法复制粘贴,影响写作效率。本脚本通过拦截网页相关检测,覆盖返回空值,从而解除禁止粘贴限制。 ```JavaScript // ==UserScript== // @name 批改网解除禁止粘贴 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 解除批改网作文禁止粘贴限制 // @author LMINYO // @match *://*.pigai.org/* // @match *://pigai.org/* // @grant unsafeWindow // @run-at document-end // ==/UserScript== (function() { 'use strict'; var script = document.createElement('script'); script.textContent = ` (function() { console.log('[批改网解锁] 开始'); var _alert = window.alert; window.alert = function(msg) { if (msg && msg.indexOf('禁止粘贴') !== -1) { console.log('[批改网解锁] 拦截弹窗'); return; } return _alert.call(window, msg); }; window.init_no_paste = function() {}; Object.defineProperty(window, '_no_paste', { get: function() { return "0"; }, set: function() {}, configurable: true }); function unlock() { document.onpaste = null; document.oncopy = null; document.oncut = null; var el = document.getElementById('contents'); if (el) { el.onpaste = null; el.oncopy = null; el.oncut = null; } document.querySelectorAll('.no_paste').forEach(function(e) { e.classList.remove('no_paste'); }); if (window.$) { $(document).off('paste copy cut'); $('#contents').off('paste copy cut'); $('.no_paste').off('paste copy cut contextmenu selectstart'); } } unlock(); setTimeout(unlock, 500); setTimeout(unlock, 1000); setTimeout(unlock, 2000); setInterval(unlock, 1000); console.log('[批改网解锁] 完成'); })(); `; document.body.appendChild(script); script.remove(); })(); ``` ## 代码解析 做了几个步骤 通过拦截alart覆盖返回空值 使用 Object.defineProperty 劫持锁定 _no\_paste该变量的读写,无论浏览器如何设置,读取都是0返回值 禁用init_\_no \_paste函数,阻止初始化_ 设置定时器防止动态恢复 <br /> <br /> <br /> 最后修改:2026 年 04 月 11 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏