Add a UserScript build
This commit is contained in:
		
							parent
							
								
									5fe04c5882
								
							
						
					
					
						commit
						d26196d6c5
					
				
					 3 changed files with 64 additions and 16 deletions
				
			
		
							
								
								
									
										15
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							|  | @ -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 | ||||
|  |  | |||
							
								
								
									
										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…
	
	Add table
		Add a link
		
	
		Reference in a new issue