aboutsummaryrefslogtreecommitdiff
path: root/scripts/build
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-12-01 06:32:52 +0100
committernea <romangraef@gmail.com>2022-12-01 06:44:49 +0100
commit05fe47dd2050fb5b0e5f90598526adf70b4e0ed1 (patch)
tree409e41d4d094c9e5108556bbe402497659b8ea48 /scripts/build
parent734054ff68a103482bff903bb384bc24576c5499 (diff)
downloadVencord-05fe47dd2050fb5b0e5f90598526adf70b4e0ed1.tar.gz
Vencord-05fe47dd2050fb5b0e5f90598526adf70b4e0ed1.tar.bz2
Vencord-05fe47dd2050fb5b0e5f90598526adf70b4e0ed1.zip
Add Manifest V2 support
Because there are so few differences between manifest v2 and v3 aside from header rewriting i just wrote two different manifests. Right now this only works on firefox with unpacked extensions.
Diffstat (limited to 'scripts/build')
-rwxr-xr-xscripts/build/buildWeb.mjs40
1 files changed, 23 insertions, 17 deletions
diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs
index a4ad87f..74f0857 100755
--- a/scripts/build/buildWeb.mjs
+++ b/scripts/build/buildWeb.mjs
@@ -72,20 +72,26 @@ await Promise.all(
]
);
-zip({
- dist: {
- "Vencord.js": readFileSync("dist/browser.js")
- },
- ...Object.fromEntries(await Promise.all(["modifyResponseHeaders.json", "content.js", "manifest.json"].map(async f => [
- f,
- await readFile(join("browser", f))
- ]))),
-}, {}, (err, data) => {
- if (err) {
- console.error(err);
- process.exitCode = 1;
- } else {
- writeFileSync("dist/extension.zip", data);
- console.info("Extension written to dist/extension.zip");
- }
-});
+async function buildPluginZip(target, files) {
+ zip({
+ dist: {
+ "Vencord.js": readFileSync("dist/browser.js")
+ },
+ ...Object.fromEntries(await Promise.all(files.map(async f => [
+ (f.startsWith("manifest") ? "manifest.json" : f),
+ await readFile(join("browser", f))
+ ]))),
+ }, {}, (err, data) => {
+ if (err) {
+ console.error(err);
+ process.exitCode = 1;
+ } else {
+ writeFileSync("dist/" + target, data);
+ console.info("Extension written to dist/" + target);
+ }
+ });
+}
+
+await buildPluginZip("extension-v3.zip", ["modifyResponseHeaders.json", "content.js", "manifestv3.json"]);
+await buildPluginZip("extension-v2.xpi", ["background.js", "content.js", "manifestv2.json"]);
+