// ==UserScript== // @name 天大评教助手 (自动好评) // @namespace http://tampermonkey.net/ // @version 1.0 // @description 适配 saa.tju.edu.cn,自动选择所有题目为“非常满意/非常同意”(最后一项)并填充随机评语。 // @author 24智医L77 // @match *://saa.tju.edu.cn/eams/* // @match *://saa.tju.edu.cn/* // @grant none // ==/UserScript== (function() { 'use strict'; // 评语库配置 const COMMENTS = [ "老师授课重点突出,条理清晰,板书工整。", "教学内容丰富,理论联系实际,受益匪浅。", "课堂氛围活跃,老师很有耐心,讲解透彻。", "课程结构清晰,进度安排合理,老师治学严谨。", "老师备课充分,对学生负责,教学效果很好。" ]; // 清理可能存在的旧按钮 function clearOldButtons() { const ids = ['tju-helper-btn', 'tju-auto-rate-btn']; ids.forEach(id => document.getElementById(id)?.remove()); } // 执行评教逻辑 function runTask() { const radios = document.querySelectorAll('input[type="radio"]'); if (radios.length === 0) return; // 1. 自动选择最后一项 (优秀/非常满意) const groups = {}; radios.forEach(radio => { if (!groups[radio.name]) groups[radio.name] = []; groups[radio.name].push(radio); }); let count = 0; for (const name in groups) { const options = groups[name]; if (options.length > 0) { options[options.length - 1].click(); // 点击最后一个选项 count++; } } // 2. 随机填充评语 const textareas = document.querySelectorAll('textarea'); textareas.forEach(area => { area.value = COMMENTS[Math.floor(Math.random() * COMMENTS.length)]; area.dispatchEvent(new Event('input')); // 触发输入事件 area.dispatchEvent(new Event('change')); }); console.log(`已自动填写 ${count} 道题目`); } // 创建悬浮按钮 function createButton() { clearOldButtons(); // 仅在检测到题目时显示按钮 if (document.querySelectorAll('input[type="radio"]').length === 0) return; const btn = document.createElement('div'); btn.id = 'tju-helper-btn'; btn.innerHTML = '⚡ 一键好评'; btn.style.cssText = ` position: fixed; top: 20%; right: 20px; z-index: 99999; background: #003366; color: white; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); user-select: none; `; btn.onclick = () => { runTask(); btn.innerHTML = '✅ 已填写'; setTimeout(() => btn.innerHTML = '⚡ 一键好评', 2000); }; document.body.appendChild(btn); } // 延迟加载以等待页面渲染 setTimeout(createButton, 1000); setTimeout(createButton, 2000); })();