// ==UserScript== // @name 强智教务系统自动评教(全自动增强版) // @namespace https://github.com/tomatox64/qiangzhi-auto-evaluation // @version 2.1.2 // @description 基于小哲《强智教务系统自动评教(通用版)》v1.1 二次开发:新增可开关的全自动模式,自动识别未评课程→按原评分策略填充→等待15秒→提交→下一门;针对湖南工商大学 jwgl.hutb.edu.cn 适配弹窗入口、带空格按钮与隐藏 iframe 提交。评分规则与原版一致。 // @author 小哲(Gemini-3-pro辅助开发) // @license MIT // @homepageURL https://github.com/tomatox64/qiangzhi-auto-evaluation // @supportURL https://github.com/tomatox64/qiangzhi-auto-evaluation/issues // @tag 自动评教 // @match *://*/jsxsd/* // @match *://*/*jsxsd/* // @match http://192.168.100.7/* // @icon https://img.icons8.com/fluency/64/maintenance.png // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_addElement // @grant CAT_scriptLoaded // @grant unsafeWindow // @run-at document-start // @early-start // ==/UserScript== /*! * 强智教务系统自动评教(全自动增强版) * 来源:基于 小哲《强智教务系统自动评教(通用版)》v1.1 二次开发 * 原脚本 https://scriptcat.org/zh-CN/script-show-page/4997 * 本版新增:全自动模式 / 提交前等待可配置 / 跨页面状态机 / alert·confirm 接管 * 站点适配:湖南工商大学 jwgl.hutb.edu.cn(openWindow 入口、带空格按钮、隐藏 iframe 提交) * 项目主页:https://github.com/tomatox64/qiangzhi-auto-evaluation * 许可:MIT */ (function () { 'use strict'; // ============================================================ // 0. 弹窗接管 —— 必须最先执行 // 强智提交后返回的页面常用内联 alert('保存成功') 再跳转, // 原生弹窗会冻结渲染线程。这里抢在页面脚本之前改写 // window.alert/confirm,把文案写进 DOM 供脚本读取。 // ============================================================ function qztAutoAtLoad() { try { const raw = GM_getValue('qzt_settings_v3'); const s = typeof raw === 'string' ? JSON.parse(raw) : raw; return !!(s && s.autoMode); } catch (e) { return false; } } function qztWriteDialog(kind, msg) { try { const d = document.documentElement; if (d) d.setAttribute('data-qzt-dialog', kind + ':' + String(msg).slice(0, 500) + '|' + Date.now()); } catch (e) { /* ignore */ } } function installDialogHook() { const autoAtLoad = qztAutoAtLoad(); const swallow = () => { try { const d = document.documentElement; if (!d) return autoAtLoad; const a = d.getAttribute('data-qzt-auto'); if (a === null) return autoAtLoad; return a === '1' && d.getAttribute('data-qzt-confirm') !== '0'; } catch (e) { return autoAtLoad; } }; // ① 直接改写页面 window:同步生效,不依赖 GM 消息往返 try { const w = (typeof unsafeWindow !== 'undefined' && unsafeWindow) ? unsafeWindow : window; if (w && !w.__qztDialogHooked) { w.__qztDialogHooked = true; const origAlert = w.alert, origConfirm = w.confirm; w.alert = function (m) { qztWriteDialog('alert', m); if (swallow()) return; try { return origAlert.apply(w, arguments); } catch (e) { return; } }; w.confirm = function (m) { qztWriteDialog('confirm', m); if (swallow()) return true; try { return origConfirm.apply(w, arguments); } catch (e) { return true; } }; try { document.documentElement.setAttribute('data-qzt-hook', '1'); } catch (e) { /* ignore */ } } } catch (e) { /* ignore */ } if (hookActive()) return; // ② GM_addElement 注入(绕过页面 CSP) const code = `(function () { if (window.__qztDialogHooked) return; window.__qztDialogHooked = true; var origAlert = window.alert, origConfirm = window.confirm; function autoOn() { var d = document.documentElement; if (!d) return false; return d.getAttribute('data-qzt-auto') === '1' && d.getAttribute('data-qzt-confirm') !== '0'; } function record(kind, msg) { try { var d = document.documentElement; d.setAttribute('data-qzt-dialog', kind + ':' + String(msg).slice(0, 500) + '|' + Date.now()); } catch (e) {} } window.alert = function (m) { record('alert', m); if (autoOn()) return; try { return origAlert.apply(window, arguments); } catch (e) { return; } }; window.confirm = function (m) { record('confirm', m); if (autoOn()) return true; try { return origConfirm.apply(window, arguments); } catch (e) { return true; } }; try { document.documentElement.setAttribute('data-qzt-hook', '1'); } catch (e) {} })();`; try { GM_addElement('script', { textContent: code }); } catch (e) { /* 继续兜底 */ } if (hookActive()) return; // ③ 直接插