// ==UserScript== // @name hjsf教评自动填写 // @namespace http://tampermonkey.net/ // @version 1.0 // @match http://jwgl.hjnu.edu.cn:82/* // @match https://webvpn.hjnu.edu.cn/* // @grant GM_addStyle //@description 一键勾选全部满分选项,自动随机填充好评文本,手动保存后自动顺序切换下一位老师,无需重复点击按钮 // @run-at document-end // @license MIT // ==/UserScript== (function() { 'use strict'; GM_addStyle(` #allCheckBtn { position: fixed !important; top: 140px !important; right: 15px !important; z-index: 9999999 !important; padding: 10px 16px !important; background: #0052cc !important; color: #fff !important; border: none !important; border-radius: 6px !important; cursor: pointer !important; box-shadow: 0 2px 8px #0003 !important; pointer-events: auto !important; } `); // 全局变量 let currentRowId = null; let switchLock = false; // 【修复】补充延时函数,解决sleep未定义 function sleep(minMs, maxMs) { const t = Math.floor(Math.random() * (maxMs - minMs) + minMs); return new Promise(res => setTimeout(res, t)); } // XPath工具 function getXPathAll(xpathStr) { const list = []; const res = document.evaluate(xpathStr, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for(let i=0; i { input.checked = true; input.dispatchEvent(new Event("change", {bubbles:true})); }); fillTextarea(); alert(`当前老师勾选填写完成,请手动点击页面保存按钮`); } // 【修复监听】监听右侧评教表单容器是否消失,不是保存按钮 const saveObserver = new MutationObserver(async () => { // 恢复原表单容器xpath,表单消失=保存成功 const formBox = getXPathOne('/html/body/div[2]/div/div/div[4]/div[2]/div/div[3]/form'); if (!formBox && currentRowId && !switchLock) { await clickNextTeacherRow(); } }); saveObserver.observe(document.body, { childList: true, subtree: true }); // 创建悬浮按钮 function createBtn() { if(document.getElementById("allCheckBtn")) return; const btn = document.createElement("button"); btn.id = "allCheckBtn"; btn.textContent = "一键全选表格复选框"; btn.onclick = checkAllTableBox; document.body.appendChild(btn); } window.addEventListener("DOMContentLoaded", createBtn); setTimeout(createBtn, 800); const observer = new MutationObserver(() => createBtn()); observer.observe(document.body, {childList:true, subtree:true}); })();