// ==UserScript== // @name Monaco/头歌/学习通 通用代码增强工具 // @namespace http://tampermonkey.net/ // @version 4.1 // @description 统一适配 Monaco / 头歌 / CodeMirror 编辑器:提取 + 复制 + 写入 // @match *://*.chaoxing.com/* // @match *://*.edu.cn/* // @match *://*.educoder.net/* // @match *://*.headgo*/* // @grant none // @run-at document-start // @author sikoll // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/574278/Monaco%E5%A4%B4%E6%AD%8C%E5%AD%A6%E4%B9%A0%E9%80%9A%20%E9%80%9A%E7%94%A8%E4%BB%A3%E7%A0%81%E5%A2%9E%E5%BC%BA%E5%B7%A5%E5%85%B7.user.js // @updateURL https://update.greasyfork.icu/scripts/574278/Monaco%E5%A4%B4%E6%AD%8C%E5%AD%A6%E4%B9%A0%E9%80%9A%20%E9%80%9A%E7%94%A8%E4%BB%A3%E7%A0%81%E5%A2%9E%E5%BC%BA%E5%B7%A5%E5%85%B7.meta.js // ==/UserScript== (function() { 'use strict'; // 阻止页面阻止粘贴 document.addEventListener('paste', function(e) { e.stopImmediatePropagation(); }, true); // 允许所有输入框粘贴 const allowPaste = () => { document.querySelectorAll('input, textarea, [contenteditable="true"]').forEach(el => { el.onpaste = null; el.style.userSelect = 'text'; }); }; // 监听动态加载的iframe(学习通常用iframe编辑器) const observer = new MutationObserver(() => { allowPaste(); document.querySelectorAll('iframe').forEach(iframe => { try { if (iframe.contentDocument) { iframe.contentDocument.addEventListener('paste', e => e.stopImmediatePropagation(), true); const frameObserver = new MutationObserver(allowPaste); frameObserver.observe(iframe.contentDocument.body, { childList: true, subtree: true }); } } catch(e) {} }); }); observer.observe(document.body, { childList: true, subtree: true }); allowPaste(); console.log('✅ 学习通粘贴限制已解除!Ctrl+V 试试看'); })();