Greasy Fork is available in English.
统一适配 Monaco / 头歌 / CodeMirror 编辑器:提取 + 复制 + 写入
// ==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
// ==/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 试试看');
})();