Add a UserScript build
This commit is contained in:
parent
5fe04c5882
commit
d26196d6c5
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -53,6 +53,7 @@ jobs:
|
||||
draft: false
|
||||
prerelease: false
|
||||
files: |
|
||||
dist/Vencord.user.js
|
||||
dist/browser.js
|
||||
dist/extension.zip
|
||||
dist/renderer.js
|
||||
|
23
browser/userscript.meta.js
Normal file
23
browser/userscript.meta.js
Normal file
@ -0,0 +1,23 @@
|
||||
// ==UserScript==
|
||||
// @name Vencord
|
||||
// @description A Discord client mod - Web version
|
||||
// @version %version%
|
||||
// @author Vendicated (https://github.com/Vendicated)
|
||||
// @namespace https://github.com/Vendicated/Vencord
|
||||
// @supportURL https://github.com/Vendicated/Vencord
|
||||
// @license GPL-3.0
|
||||
// @match *://*.discord.com/*
|
||||
// @grant none
|
||||
// @run-at document-start
|
||||
// @compatible chrome Chrome + Tampermonkey or Violentmonkey
|
||||
// @compatible firefox Firefox Tampermonkey
|
||||
// @compatible opera Opera + Tampermonkey or Violentmonkey
|
||||
// @compatible edge Edge + Tampermonkey or Violentmonkey
|
||||
// @compatible safari Safari + Tampermonkey or Violentmonkey
|
||||
// ==/UserScript==
|
||||
|
||||
// this UserScript DOES NOT work on Firefox with Violentmonkey or Greasemonkey due to a bug that makes it impossible
|
||||
// to overwrite stuff on the window on sites that use CSP. Use Tampermonkey or use a chromium based browser
|
||||
// https://github.com/violentmonkey/violentmonkey/issues/997
|
||||
|
||||
// this is a compiled and minified version of Vencord. For the source code, visit the GitHub repo
|
42
buildWeb.mjs
42
buildWeb.mjs
@ -1,9 +1,11 @@
|
||||
// TODO: Modularise these plugins since both build scripts use them
|
||||
|
||||
import { execSync } from "child_process";
|
||||
import { createWriteStream, readdirSync } from "fs";
|
||||
import { createWriteStream, readdirSync, readFileSync } from "fs";
|
||||
import yazl from "yazl";
|
||||
import esbuild from "esbuild";
|
||||
// wtf is this assert syntax
|
||||
import PackageJSON from "./package.json" assert { type: "json" };
|
||||
|
||||
/**
|
||||
* @type {esbuild.Plugin}
|
||||
@ -56,23 +58,45 @@ const gitHashPlugin = {
|
||||
}
|
||||
};
|
||||
|
||||
await esbuild.build({
|
||||
/**
|
||||
* @type {esbuild.BuildOptions}
|
||||
*/
|
||||
const commonOptions = {
|
||||
logLevel: "info",
|
||||
entryPoints: ["browser/Vencord.ts"],
|
||||
outfile: "dist/browser.js",
|
||||
globalName: "Vencord",
|
||||
format: "iife",
|
||||
bundle: true,
|
||||
globalName: "Vencord",
|
||||
target: ["esnext"],
|
||||
footer: { js: "//# sourceURL=VencordWeb" },
|
||||
minify: true,
|
||||
sourcemap: false,
|
||||
external: ["plugins", "git-hash"],
|
||||
plugins: [
|
||||
globPlugins,
|
||||
gitHashPlugin
|
||||
],
|
||||
sourcemap: false,
|
||||
minify: true,
|
||||
});
|
||||
target: ["esnext"],
|
||||
};
|
||||
|
||||
await Promise.all(
|
||||
[
|
||||
esbuild.build({
|
||||
...commonOptions,
|
||||
outfile: "dist/browser.js",
|
||||
footer: { js: "//# sourceURL=VencordWeb" },
|
||||
}),
|
||||
esbuild.build({
|
||||
...commonOptions,
|
||||
outfile: "dist/Vencord.user.js",
|
||||
banner: {
|
||||
js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", PackageJSON.version)
|
||||
},
|
||||
footer: {
|
||||
// UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local
|
||||
js: "Object.defineProperty(window,'Vencord',{get:()=>Vencord});"
|
||||
},
|
||||
})
|
||||
]
|
||||
);
|
||||
|
||||
const zip = new yazl.ZipFile();
|
||||
zip.outputStream.pipe(createWriteStream("dist/extension.zip")).on("close", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user