// ==UserScript== // @name 【超星学习通助手】更新AI解答+视频+测试+考试(使用AI进行答题) // @namespace li_stu // @version 2.41 // @description 基于脚本猫 1693(unrival,GPL-3.0)二次开发并持续维护(维护者 li_stu);第三方AI模型(OpenAI兼容接口,提示词固定前置提升缓存命中率,统计AI调用次数与缓存命中率,支持SSE流式响应解析,可跳过已作答题目,支持NuoAPI一键获取密钥);学习通面板内置AI问答(直接调用LLM设置里保存的接口);支持图片/听力题文本化、图书/链接/速课/直播任务、单实例运行与多窗口提示 // @name:zh-TW 【超星學習通助手】更新AI解答+影片+測驗+考試(AI輔助) // @name:en Chaoxing Learning Assistant [AI Answer][Video][Quiz][Exam] // @description:zh-TW 基於腳本貓 1693(unrival,GPL-3.0)二次開發並持續維護(維護者 li_stu);第三方AI模型輔助(OpenAI相容介面,提示詞固定前置提升快取命中率,統計AI呼叫次數與快取命中率,支援SSE串流回應解析,可跳過已作答題目,支援NuoAPI一鍵取得金鑰);學習通面板內建AI問答(直接呼叫LLM設定中儲存的介面);支援圖片/聽力題文字化、圖書/連結/速課/直播任務、單實例執行與多視窗提示 // @description:en Derived from ScriptCat 1693 by unrival (GPL-3.0), maintained by li_stu. Adds a freely configurable OpenAI-compatible LLM helper (cache-friendly prompt order, AI call/cache-hit stats, SSE streaming parsing, skip answered questions, NuoAPI key shortcut), an in-panel AI chat using the saved LLM config, media-to-text question extraction, book/link/micro-course/live tasks, single-instance detection, and a multi-window course warning. // @antifeature payment 脚本会请求第三方AI接口进行答题,您可以选择停用相关功能 // @antifeature:zh-TW payment 腳本會請求第三方AI介面進行答題,您可以選擇停用相關功能 // @antifeature:en payment The script requests third-party AI APIs for answering. You can disable this feature. // @compatible firefox // @compatible chrome // @compatible edge // @author unrival, li_stu // @run-at document-end // @storageName li_stu_xxt // @match *://*.chaoxing.com/* // @match *://*.edu.cn/* // @match *://*.nbdlib.cn/* // @match *://*.hnsyu.net/* // @match *://*.ac.cn/* // @icon https://pan-yz.chaoxing.com/favicon.ico // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_info // @grant GM_getResourceText // @connect passport2-api.chaoxing.com // @connect zhibo.chaoxing.com // @connect pan-yz.chaoxing.com // @connect api.deepseek.com // @connect nuoapi.net // @connect localhost // @connect 127.0.0.1 // @connect * // 说明:以上每个域名都对应脚本里真实发起的跨域请求,可逐条核对: // passport2-api.chaoxing.com 登录态校验与用户信息 // zhibo.chaoxing.com 直播回放观看进度上报 // pan-yz.chaoxing.com 仅用于 @icon 图标与运行日志截图,非接口请求 // api.deepseek.com / nuoapi.net / localhost / 127.0.0.1 内置 AI 预设 // AI 接口地址由用户在「LLM 配置」中自行填写(DeepSeek / Ollama / NuoAPI / 其他 OpenAI 兼容服务), // 目标域名无法在打包时枚举,因此保留 `*`;声明具体域名只为让审核能对上代码,不缩小用户可用范围。 // @resource Vue https://lib.baomitu.com/vue/2.6.0/vue.min.js // @resource ElementUi https://lib.baomitu.com/element-ui/2.15.13/index.js // @resource ElementUiCss https://lib.baomitu.com/element-ui/2.15.13/theme-chalk/index.min.css // @resource Table https://www.forestpolice.org/ttf/2.0/table.json // 字体映射表来源:脚本猫 432《超星字体解密》作者 wyn665817(MIT), // 原表由该作者生成;forestpolice.org 仅为当前可用的静态托管镜像。 // 若该站失效,可换任意同内容托管地址,不影响字体解密逻辑。 // @require https://lib.baomitu.com/axios/0.27.2/axios.min.js // @require https://lib.baomitu.com/cryptico/0.0.1343522940/hash.min.js // @require https://lib.baomitu.com/jquery/3.6.0/jquery.min.js // @require https://lib.baomitu.com/promise-polyfill/8.3.0/polyfill.min.js // @license GPL-3.0-or-later // @homepageURL https://github.com/hjm-al/chaoxing-assistant // @supportURL https://github.com/hjm-al/chaoxing-assistant/issues // @source https://github.com/hjm-al/chaoxing-assistant // @original-script https://scriptcat.org/zh-CN/script-show-page/1693 // @original-author unrival // @original-license GPL-3.0-or-later // @thanks 脚本猫 1693《超星学习通助手》作者 unrival // @thanks 脚本猫 379《正则脚本》作者 张正则(原版,已下线) // @thanks GitHub Looong01/Zhihuishu-Automatic-Answering 作者 Loong(BUPT) // @thanks GitHub Black-Cyan/chaoxing 作者 Black-Cyan // @thanks 脚本猫 432《超星字体解密》作者 wyn665817 // @thanks 脚本猫 367《OCS 网课助手》作者 言小溪enncy // @thanks Greasy Fork 28497《网页限制解除(改)》作者 qxinGitHub // @thanks 脚本猫 616 / Greasy Fork 451356《【万能】全平台自动答题脚本》作者 万能(Greasy Fork: xmig666) // @tag 超星学习通 // @tag 学习辅助 // @tag 答题辅助 // @tag AI答题 // @tag 自动播放 // @tag 在线教育 // @tag AI辅助 // ==/UserScript== // 如需新增安全网址(@connect),请在上方元数据块内的 @connect 列表中补充,一行一个。 // ============================================================================ // 来源与署名 // // 原始版本:脚本猫 1693《超星学习通助手》,作者 unrival,许可证 GPL-3.0-or-later。 // 本脚本:在该版本基础上二次开发并持续维护(维护者 li_stu),沿用 // GPL-3.0-or-later 分发,许可证全文见仓库 LICENSE。 // 二次分发必须附带完整源码、保留原作者署名,不得闭源或混淆打包。 // // 致谢清单 // 以下项目在本脚本开发过程中提供了思路、接口约定或行为对照。此处仅作参考登记, // 本脚本未复制它们的代码。一行一项,括号内为许可证: // - 脚本猫 379《正则脚本》— 张正则(原版已下线,未标注许可证) // - Zhihuishu-Automatic-Answering — Loong / BUPT(MIT) // - chaoxing — Black-Cyan(Apache-2.0) // - 脚本猫 432《超星字体解密》— wyn665817(MIT) // - 脚本猫 367《OCS 网课助手》— 言小溪 enncy(MIT) // - Greasy Fork 28497《网页限制解除(改)》— qxinGitHub(LGPL-3.0) // - 脚本猫 616 / Greasy Fork 451356《【万能】全平台自动答题脚本》— 万能(未标注许可证) // // 关于 616 / 451356 的边界说明(一行一条): // 1. 重合范围仅限「早期答题框架与接口约定」:WorkerJS 与 GLOBAL 配置对象、answerApi.tikuAdapter / tiku_adapter 题库适配约定、考试页路径匹配写法。 // 2. 上述内容在仓库归档的 v1.46 快照里已全部存在,属于 unrival 代码线的既成部分,不是本脚本新增的搬用。 // 3. 该项目在脚本页与 Greasy Fork 页的许可证字段均为空,本脚本不能以它作为授权来源,也不对它做任何再许可。 // 4. 它后期加入的题库直连与多 host 探测(getFastHost / probeHosts、tiku168.net)未被本脚本采用。 // 5. v2.37 已把沿用该家族写法却与本脚本无关的答案上报、广告位实现整体移除:reportOnline、url2Base64、adList、hookHTML、uploadAnswer、scriptService、baseService。 // ============================================================================ var XXTFoundation = (function () { var logPrefix = "[XXT]"; function get(key, fallback) { try { var value = GM_getValue(key); return value === undefined ? fallback : value; } catch (error) { log("warn", "读取设置失败:" + key, error); return fallback; } } function set(key, value) { try { GM_setValue(key, value); return true; } catch (error) { log("warn", "保存设置失败:" + key, error); return false; } } function text(value, fallback) { var normalized = String(value == null ? "" : value).trim(); return normalized || (fallback || ""); } function number(value, fallback, minimum) { var parsed = Number(value); if (!isFinite(parsed) || (minimum != null && parsed < minimum)) return fallback; return parsed; } function enabled(value) { return value === true || value === "true" || value === 1 || value === "1"; } function log(level, message, detail) { var method = console && typeof console[level] === "function" ? level : "log"; if (detail === undefined) console[method](logPrefix + " " + message); else console[method](logPrefix + " " + message, detail); } function request(options) { if (!options || typeof options !== "object") { return Promise.reject(new TypeError("请求配置无效")); } return new Promise(function (resolve, reject) { var requestOptions = Object.assign({}, options); var onload = requestOptions.onload; var onerror = requestOptions.onerror; requestOptions.onload = function (response) { if (typeof onload === "function") onload(response); resolve(response); }; requestOptions.onerror = function (error) { if (typeof onerror === "function") onerror(error); reject(error); }; try { GM_xmlhttpRequest(requestOptions); } catch (error) { if (typeof onerror === "function") onerror(error); reject(error); } }); } return { get: get, set: set, text: text, number: number, enabled: enabled, log: log, request: request }; })(); function aiPanelMessage(type, message, sourceWindow) { var current = sourceWindow || (typeof unsafeWindow !== 'undefined' ? unsafeWindow : window); while (current) { try { var frame = current.document.getElementById('iframeNode'); if (frame && frame.contentWindow && typeof frame.contentWindow.vueDefinedProp === 'function') { frame.contentWindow.vueDefinedProp(type, message); return true; } if (current === current.parent) break; current = current.parent; } catch (error) { break; } } return false; } function aiRemovePanel(sourceWindow, owner) { var current = sourceWindow || (typeof unsafeWindow !== 'undefined' ? unsafeWindow : window); while (current) { try { var panel = current.document.getElementById('modelId_xx'); if (panel && panel.querySelector('#iframeNode') && (!owner || panel.dataset.xxtOwner === owner)) { panel.remove(); return true; } if (current === current.parent) break; current = current.parent; } catch (error) { break; } } return false; } // ============================================================================ // UI 模块:悬浮答题面板 / 学习通主页面板 / LLM 配置面板 / 保存提示 // 四套 HTML 模板与公共设计令牌只在这里定义一份,其它位置一律通过 XXT_UI 取用, // 避免同一份样式与结构重复维护、改一处漏三处。 // ============================================================================ var XXT_UI = (function () { var TOKENS = ":root {\n color-scheme: light;\n --xxt-ink: #243447;\n --xxt-muted: #718096;\n --xxt-line: #e6ebf1;\n --xxt-surface: #ffffff;\n --xxt-soft: #f5f8fb;\n --xxt-accent: #3b82f6;\n}"; var PANEL_HTML = `
考试端 · 题目处理状态
运行日志
答题记录
AI 问答
{{ chatStatus }}