feat: add portable role-based question bank assistant

This commit is contained in:
薇星幻海
2026-10-10 03:39:43 +08:00
parent e265983170
commit 0ea302bbab
18 changed files with 4659 additions and 330 deletions
+18 -8
View File
@@ -3,17 +3,27 @@ import { readFileSync, writeFileSync } from 'node:fs';
const metadata = `// ==UserScript==
// @name 谊安学练习题库自动导出
// @namespace yianxue-question-bank
// @version 1.0.0
// @description 进入练习后自动导出题干、选项、参考答案和解析;读取隐藏答案。
// @match http://10.119.67.7/clientcn/*
// @match https://10.119.67.7/clientcn/*
// @version 2.0.0
// @description 不绑定网址的题库助手:岗位题库搜索、允许复制、练习自动选择与导出。
// @match *://*/*
// @match file:///*
// @run-at document-idle
// @grant none
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_setClipboard
// @noframes
// ==/UserScript==
`;
const core = readFileSync(new URL('./question-bank-core.js', import.meta.url), 'utf8');
const automation = readFileSync(new URL('./practice-exporter.js', import.meta.url), 'utf8');
writeFileSync(new URL('./谊安学题库导出.user.js', import.meta.url), metadata + '\n' + core + '\n' + automation, 'utf8');
const zip = readFileSync(new URL('./vendor/jszip.min.js', import.meta.url), 'utf8');
const zipLicense = readFileSync(new URL('./vendor/LICENSE-JSZip.md', import.meta.url), 'utf8').split(/\r?\nGPL version 3/)[0];
const pakoLicense = readFileSync(new URL('./vendor/LICENSE-pako.txt', import.meta.url), 'utf8');
const notices = '/* Third-party notices: JSZip and pako distributed under their MIT licenses.\n'
+ zipLicense + '\n' + pakoLicense + '\n*/\n';
// 用局部 CommonJS 环境加载内置 ZIP 库,避免被网页的 AMD / require 接管。
const zipWrapper = '(function () { const module = { exports: {} }; const exports = module.exports;\n'
+ zip + '\nwindow.JSZip = module.exports;\n})();\n';
const modules = ['question-bank-core.js', 'bank-store.js', 'answer-matcher.js',
'copy-controller.js', 'assistant-panel.js', 'answer-runner.js', 'practice-exporter.js'];
const source = modules.map(name => readFileSync(new URL('./' + name, import.meta.url), 'utf8')).join('\n');
writeFileSync(new URL('./谊安学题库导出.user.js', import.meta.url), metadata + '\n' + notices + zipWrapper + source, 'utf8');
console.log('已生成 谊安学题库导出.user.js');