Add a UserScript build
This commit is contained in:
parent
5fe04c5882
commit
d26196d6c5
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
|
@ -4,7 +4,7 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
env:
|
env:
|
||||||
FORCE_COLOR: true
|
FORCE_COLOR: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Build:
|
||||||
|
@ -34,14 +34,14 @@ jobs:
|
||||||
id: vars
|
id: vars
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||||
|
|
||||||
- uses: dev-drprasad/delete-tag-and-release@085c6969f18bad0de1b9f3fe6692a3cd01f64fe5 # v0.2.0
|
- uses: dev-drprasad/delete-tag-and-release@085c6969f18bad0de1b9f3fe6692a3cd01f64fe5 # v0.2.0
|
||||||
with:
|
with:
|
||||||
delete_release: true
|
delete_release: true
|
||||||
tag_name: devbuild
|
tag_name: devbuild
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Create the release
|
- name: Create the release
|
||||||
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
|
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
|
||||||
|
@ -53,6 +53,7 @@ jobs:
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
files: |
|
files: |
|
||||||
|
dist/Vencord.user.js
|
||||||
dist/browser.js
|
dist/browser.js
|
||||||
dist/extension.zip
|
dist/extension.zip
|
||||||
dist/renderer.js
|
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
|
// TODO: Modularise these plugins since both build scripts use them
|
||||||
|
|
||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
import { createWriteStream, readdirSync } from "fs";
|
import { createWriteStream, readdirSync, readFileSync } from "fs";
|
||||||
import yazl from "yazl";
|
import yazl from "yazl";
|
||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
|
// wtf is this assert syntax
|
||||||
|
import PackageJSON from "./package.json" assert { type: "json" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {esbuild.Plugin}
|
* @type {esbuild.Plugin}
|
||||||
|
@ -56,23 +58,45 @@ const gitHashPlugin = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await esbuild.build({
|
/**
|
||||||
|
* @type {esbuild.BuildOptions}
|
||||||
|
*/
|
||||||
|
const commonOptions = {
|
||||||
logLevel: "info",
|
logLevel: "info",
|
||||||
entryPoints: ["browser/Vencord.ts"],
|
entryPoints: ["browser/Vencord.ts"],
|
||||||
outfile: "dist/browser.js",
|
globalName: "Vencord",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
bundle: true,
|
bundle: true,
|
||||||
globalName: "Vencord",
|
minify: true,
|
||||||
target: ["esnext"],
|
sourcemap: false,
|
||||||
footer: { js: "//# sourceURL=VencordWeb" },
|
|
||||||
external: ["plugins", "git-hash"],
|
external: ["plugins", "git-hash"],
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins,
|
globPlugins,
|
||||||
gitHashPlugin
|
gitHashPlugin
|
||||||
],
|
],
|
||||||
sourcemap: false,
|
target: ["esnext"],
|
||||||
minify: true,
|
};
|
||||||
});
|
|
||||||
|
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();
|
const zip = new yazl.ZipFile();
|
||||||
zip.outputStream.pipe(createWriteStream("dist/extension.zip")).on("close", () => {
|
zip.outputStream.pipe(createWriteStream("dist/extension.zip")).on("close", () => {
|
||||||
|
|
Loading…
Reference in a new issue