aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml15
-rw-r--r--browser/userscript.meta.js23
-rw-r--r--buildWeb.mjs42
3 files changed, 64 insertions, 16 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1639c63..82b17c7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,7 +4,7 @@ on:
branches:
- main
env:
- FORCE_COLOR: true
+ FORCE_COLOR: true
jobs:
Build:
@@ -26,22 +26,22 @@ jobs:
- name: Build web
run: pnpm buildWeb
-
+
- name: Build
run: pnpm build
-
+
- name: Get some values needed for the release
id: vars
shell: bash
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
with:
- delete_release: true
- tag_name: devbuild
+ delete_release: true
+ tag_name: devbuild
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create the release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
@@ -53,6 +53,7 @@ jobs:
draft: false
prerelease: false
files: |
+ dist/Vencord.user.js
dist/browser.js
dist/extension.zip
dist/renderer.js
diff --git a/browser/userscript.meta.js b/browser/userscript.meta.js
new file mode 100644
index 0000000..e2a3de5
--- /dev/null
+++ b/browser/userscript.meta.js
@@ -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
diff --git a/buildWeb.mjs b/buildWeb.mjs
index 9031d14..afb8b33 100644
--- a/buildWeb.mjs
+++ b/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", () => {