Add basic Vencord injection
This commit is contained in:
@@ -2,6 +2,8 @@ import { app, BrowserWindow } from 'electron';
|
||||
import { createMainWindow } from "./mainWindow";
|
||||
import { createSplashWindow } from "./splash";
|
||||
|
||||
import "./ipc";
|
||||
|
||||
function createWindows() {
|
||||
const mainWindow = createMainWindow();
|
||||
const splash = createSplashWindow();
|
||||
|
||||
7
src/main/ipc.ts
Normal file
7
src/main/ipc.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { ipcMain } from "electron";
|
||||
import { GET_VENCORD } from "../shared/IpcEvents";
|
||||
import { fetchVencord } from "./vencord";
|
||||
|
||||
ipcMain.on(GET_VENCORD, async e => {
|
||||
e.returnValue = await fetchVencord();
|
||||
});
|
||||
22
src/main/vencord.ts
Normal file
22
src/main/vencord.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
const BASE_URL = "https://github.com/Vendicated/Vencord/releases/download/devbuild/";
|
||||
|
||||
let VencordScripts: Record<"js" | "css", string>;
|
||||
|
||||
async function get(url: string) {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`);
|
||||
|
||||
return res.text();
|
||||
}
|
||||
|
||||
export async function fetchVencord() {
|
||||
if (!VencordScripts) {
|
||||
const [js, css] = await Promise.all([
|
||||
get(BASE_URL + "/browser.js"),
|
||||
get(BASE_URL + "/browser.css")
|
||||
]);
|
||||
VencordScripts = { js, css };
|
||||
}
|
||||
|
||||
return VencordScripts;
|
||||
}
|
||||
Reference in New Issue
Block a user