Files
huayi-question-bank/build.cjs
T

25 lines
1.1 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.3
// @description 全网页快捷键唤出、本地题库文字检索与自动选择答案,按库导入导出;每页默认完全隐藏。
// @match *://*/*
// @run-at document-start
// @noframes
// @grant unsafeWindow
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_addValueChangeListener
// ==/UserScript==
`;
const sources = ['src/core.js', 'src/adapter.js', 'src/autofill.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}`);