-
Notifications
You must be signed in to change notification settings - Fork 5
/
dist.js
36 lines (31 loc) · 1.2 KB
/
dist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import fs from 'fs';
const packagedScriptPath = `./dist/jimaku-player.user.js`,
lastPackagedScript = fs.readFileSync(packagedScriptPath).toString(),
script = fs.readFileSync(`./build/subtitler/subtitler.js`).toString();
let versionBase = '0.6.';
const [_, oldVersion] = lastPackagedScript.match(/@version\s*\d+\.\d+\.(\d+)/);
//if packaging a release version, increment the version
if (process.argv.includes('release')) {
versionBase += parseInt(oldVersion) + 1;
} else {
versionBase += oldVersion;
}
const userscript = `// ==UserScript==
// @name 字幕プレーヤー
// @namespace https://github.com/sheodox
// @version ${versionBase}
// @description Study Japanese by using Japanese subtitles on VRV!
// @author sheodox
// @supportUrl https://github.com/sheodox/jimaku-player/issues
// @match https://static.vrv.co/vilos/player.html*
// @match https://static.crunchyroll.com/vilos-v2/web/vilos/player.html*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_setClipboard
// @connect context.reviews
// @grant GM_xmlhttpRequest
// ==/UserScript==
${script}
`;
fs.writeFileSync(packagedScriptPath, userscript);
console.log(`script packaged`);