28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const root = __dirname;
|
|
const header = `// ==UserScript==
|
|
// @name 华谊题库助手 · CSV导出与划词检索
|
|
// @namespace local.huayi.question-bank
|
|
// @version 1.2.9
|
|
// @description 全网页快捷键唤出、本地题库文字检索与自动选择答案,按库导入导出;每页默认完全隐藏。
|
|
// @match http://*/*
|
|
// @match https://*/*
|
|
// @match file:///*
|
|
// @run-at document-start
|
|
// @grant unsafeWindow
|
|
// @grant GM_getValue
|
|
// @grant GM_setValue
|
|
// @grant GM_deleteValue
|
|
// @grant GM_registerMenuCommand
|
|
// @grant GM_addValueChangeListener
|
|
// @grant GM_removeValueChangeListener
|
|
// ==/UserScript==
|
|
`;
|
|
const sources = ['src/core.js', 'src/adapter.js', 'src/autofill.js', 'src/collector.js', 'src/app.js'];
|
|
const body = sources.map(file => `\n// ---- ${file} ----\n${fs.readFileSync(path.join(root, file), 'utf8')}`).join('\n');
|
|
fs.mkdirSync(path.join(root, 'dist'), { recursive: true });
|
|
const target = path.join(root, 'dist/huayi-question-bank.user.js');
|
|
fs.writeFileSync(target, `${header}\n(function () {\n'use strict';\n${body}\n})();\n`, 'utf8');
|
|
console.log(`已生成 ${target}`);
|