feat: add draggable panel and restrict assistant to site directory

This commit is contained in:
薇星幻海
2026-10-12 14:19:31 +08:00
parent 3d7a1ffed0
commit 20abb33740
12 changed files with 968 additions and 77 deletions
+8 -5
View File
@@ -3,10 +3,9 @@ import { readFileSync, writeFileSync } from 'node:fs';
const metadata = `// ==UserScript==
// @name 谊安学助手 2.0
// @namespace yianxue-question-bank
// @version 2.0.2
// @description 不绑定网址的题库助手:岗位搜索、答案全文核对、练习及桌面考试自动选择。
// @match *://*/*
// @match file:///*
// @version 2.0.3
// @description 谊安学站点助手:可拖动面板、岗位搜索、答案全文核对及自动选择。
// @match http://10.119.67.7/clientcn/*
// @run-at document-idle
// @grant GM_getValue
// @grant GM_setValue
@@ -25,5 +24,9 @@ const zipWrapper = '(function () { const module = { exports: {} }; const exports
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('./谊安学助手 2.0.user.js', import.meta.url), metadata + '\n' + notices + zipWrapper + source, 'utf8');
const scope = readFileSync(new URL('./site-scope.js', import.meta.url), 'utf8');
// Also enforce the boundary when a manager injects manually or ignores metadata.
const bundle = '(function () {\n' + scope + '\nif (!YianSiteScope.isAllowedURL(location.href)) return;\n'
+ zipWrapper + source + '\n})();\n';
writeFileSync(new URL('./谊安学助手 2.0.user.js', import.meta.url), metadata + '\n' + notices + bundle, 'utf8');
console.log('已生成 谊安学助手 2.0.user.js');