// ==UserScript== // @name 解锁PTA复制粘贴限制 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 这个用户脚本旨在解除PTA(拼题A、Pintia)平台上的复制和粘贴限制,使用户能够自由复制和粘贴文本 // @author MadelineCarter // @match https://pintia.cn/problem-sets/*/exam/problems/* // @match https://pintia.cn/problem-sets/*/exam/* // @grant none // @license All Rights Reserved // @downloadURL none // ==/UserScript== (function () { 'use strict'; // 解锁文本选择功能 const enableTextSelection = () => { document.body.style.userSelect = 'text'; document.body.style.webkitUserSelect = 'text'; document.body.style.msUserSelect = 'text'; document.body.style.MozUserSelect = 'text'; }; // 移除特定事件监听器 const removeEventListeners = (element, events) => { events.forEach(event => { const newElement = element.cloneNode(true); element.parentNode.replaceChild(newElement, element); }); }; // 解锁复制、粘贴和拖放 const unlockClipboardRestrictions = () => { ['copy', 'paste', 'drop', 'beforeinput'].forEach(eventName => { document.addEventListener(eventName, (e) => { e.stopPropagation(); // 仅阻止限制相关的事件传播 }, true); }); }; // 兼容动态加载的内容 const observeDOMChanges = () => { const observer = new MutationObserver(() => { enableTextSelection(); unlockClipboardRestrictions(); }); observer.observe(document, { childList: true, subtree: true }); }; // 初始化解锁 const initUnlock = () => { enableTextSelection(); unlockClipboardRestrictions(); observeDOMChanges(); }; // 确保脚本延迟加载,避免与页面初始化冲突 window.addEventListener('load', () => { initUnlock(); }); })(); /* This script is not licensed for use, modification, or distribution. All rights are reserved by the author. */