您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动采集题干选项生成可复制小框,解除所有复制、选中、右键限制
// ==UserScript== // @name 考试题目与选项抽取+解锁复制 // @namespace http://ntit.edu.cn/ // @version 1.0.0 // @description 自动采集题干选项生成可复制小框,解除所有复制、选中、右键限制 // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 解锁复制/选中 var style = document.createElement('style'); style.innerHTML = ` * { user-select: text !important; } textarea { user-select: text !important; } `; document.head.appendChild(style); [ 'copy','cut','contextmenu','selectstart','mousedown','mouseup','keydown','keypress','dragstart' ].forEach(function(evt){ document.addEventListener(evt,function(e){e.stopPropagation();},true); }); function extractQuestions() { var items = document.querySelectorAll('.m-item'); var all = []; items.forEach(function(item,i){ var titleEl = item.querySelector('.examTitle p, .examTitle'); var title = (titleEl ? titleEl.innerText.trim() : '题干未检测到'); var ind = item.querySelector('.index'); var index = ind ? ind.innerText.replace(/\D/g,'') : (i+1); var options = Array.from(item.querySelectorAll('.ivu-radio-wrapper, .ivu-checkbox-wrapper')).map(function(opt, oi){ var optText = opt.innerText.trim(); var label = String.fromCharCode(65 + oi); return label + '. ' + optText; }); var full = '第' + index + '题:' + title + '\n'; if(options.length) { full += options.join('\n'); } else { var radioLabels = Array.from(item.querySelectorAll('.ivu-radio-group label, .ivu-radio-wrapper label')); if(radioLabels.length) { full += radioLabels.map(function(opt, oi){ var label = String.fromCharCode(65 + oi); return label + '. ' + opt.innerText.trim(); }).join('\n'); } } all.push(full); }); return all.join('\n\n------------------------------\n\n'); } // 等待页面加载 window.addEventListener('load', function() { setTimeout(function(){ var result = extractQuestions(); // 小号文本框 var ta = document.createElement('textarea'); ta.style = 'width:60vw;height:16vh;position:fixed;bottom:10px;left:20vw;z-index:9999;font-size:14px;'; ta.value = result; document.body.appendChild(ta); ta.focus(); ta.select(); alert('已生成题目选项小框,Ctrl+C即可复制。如果题目未加载完全可手动删除此框并刷新页面重试。'); }, 1500); // 适当延时保证页面完全渲染 }); })();