You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.1 KiB
130 lines
3.1 KiB
2 years ago
|
/* eslint-disable */
|
||
|
|
||
|
import { spawnSync } from "child_process";
|
||
|
import { writeFileSync, readFileSync, copyFileSync } from "fs";
|
||
|
|
||
|
import esbuild from "esbuild";
|
||
|
|
||
|
import webExt from "web-ext";
|
||
|
|
||
|
let res = spawnSync("git", ["rev-list", "--count", "HEAD"]);
|
||
|
let rev = +res.stdout;
|
||
|
|
||
2 years ago
|
const domains = ["https://*.4chan.org/*", "https://*.4channel.org/*", "https://sys.4chan.org/*"];
|
||
2 years ago
|
|
||
|
const manif = {
|
||
|
manifest_version: 2,
|
||
|
browser_specific_settings: {
|
||
|
gecko: {
|
||
2 years ago
|
id: "[email protected]",
|
||
2 years ago
|
update_url:
|
||
2 years ago
|
"https://git.coom.tech/araragi/JKCS/raw/branch/master/firefox_update.json",
|
||
2 years ago
|
},
|
||
|
},
|
||
2 years ago
|
name: "JannySkillersCaptchaSolver",
|
||
|
description: "The Janny Skillers Captcha Solver of choice.",
|
||
2 years ago
|
version: "0." + rev,
|
||
|
icons: {
|
||
|
64: "1449696017588.png",
|
||
|
},
|
||
|
permissions: [...domains],
|
||
|
content_scripts: [
|
||
|
{
|
||
|
matches: domains,
|
||
|
css: [],
|
||
|
run_at: "document_end",
|
||
2 years ago
|
js: ["polyfill.min.js", "dist/main.js"],
|
||
2 years ago
|
},
|
||
|
],
|
||
2 years ago
|
web_accessible_resources: ["*.html", "*.js", "*.json"],
|
||
2 years ago
|
|
||
|
// "background": {
|
||
|
// persistent: true,
|
||
|
// "scripts": [
|
||
|
// "polyfill.min.js",
|
||
|
// "browser-polyfill.min.js",
|
||
|
// "dist/background.js"
|
||
|
// ]
|
||
|
// }
|
||
|
};
|
||
|
|
||
|
(async () => {
|
||
|
let res;
|
||
|
|
||
|
res = await esbuild.build({
|
||
2 years ago
|
entryPoints: ["src/main.js"],
|
||
2 years ago
|
bundle: true,
|
||
|
treeShaking: true,
|
||
|
outdir: "./firefox/dist",
|
||
|
// outfile: "./firefox/dist/main.js",
|
||
|
define: {
|
||
|
global: "window",
|
||
|
execution_mode: '"ff_api"',
|
||
|
manifest: manif.version,
|
||
|
isBackground: "false",
|
||
|
BUILD_VERSION: JSON.stringify([0, rev]),
|
||
|
},
|
||
|
// inject: ["./esbuild.inject.js"],
|
||
|
plugins: [],
|
||
2 years ago
|
loader: { ".bin": "text" },
|
||
2 years ago
|
metafile: true,
|
||
|
});
|
||
|
|
||
|
console.log(res.metafile.inputs);
|
||
|
console.log(
|
||
|
Object.entries(res.metafile.inputs)
|
||
|
.sort((a, b) => a[1].bytes - b[1].bytes)
|
||
|
.map((e) => `${e[0]} -> ${e[1].bytes}`)
|
||
|
.join("\n")
|
||
|
);
|
||
|
/*
|
||
|
res = await esbuild.build({
|
||
|
entryPoints: ["src/background.ts"],
|
||
|
bundle: true,
|
||
|
treeShaking: true,
|
||
|
outfile: "./firefox/dist/background.js",
|
||
|
define: {
|
||
|
global: "window",
|
||
|
execution_mode: '"ff_api"',
|
||
|
manifest: manif.version,
|
||
|
isBackground: "true",
|
||
|
BUILD_VERSION: JSON.stringify([0, rev]),
|
||
|
},
|
||
|
inject: ["./esbuild.inject.js"],
|
||
|
metafile: true,
|
||
|
});
|
||
|
console.log(res.metafile.inputs);
|
||
|
console.log(
|
||
|
Object.entries(res.metafile.inputs)
|
||
|
.sort((a, b) => a[1].bytes - b[1].bytes)
|
||
|
.map((e) => `${e[0]} -> ${e[1].bytes}`)
|
||
|
.join("\n")
|
||
|
);
|
||
|
*/
|
||
|
writeFileSync("./firefox/manifest.json", JSON.stringify(manif, null, 2));
|
||
|
copyFileSync("./logo.png", "./chrome/1449696017588.png");
|
||
|
|
||
|
res = await webExt.cmd.build({
|
||
|
sourceDir: "./firefox/",
|
||
|
artifactsDir: ".",
|
||
2 years ago
|
filename: `jkcs-${manif.version}.xpi`,
|
||
2 years ago
|
overwriteDest: true,
|
||
|
});
|
||
|
console.log(res);
|
||
|
writeFileSync(
|
||
|
"./firefox_update.json",
|
||
|
JSON.stringify({
|
||
|
addons: {
|
||
2 years ago
|
"{[email protected]}": {
|
||
2 years ago
|
updates: [
|
||
|
{
|
||
|
version: manif.version,
|
||
2 years ago
|
update_link: `https://git.coom.tech/araragi/JKCS/raw/branch/master/jkcs-${manif.version}.xpi`,
|
||
2 years ago
|
},
|
||
|
],
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
);
|
||
|
})();
|