mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-23 05:35:09 +00:00
Add basic Vencord injection
This commit is contained in:
parent
5d9eb3e4fb
commit
ccaad66b1b
5 changed files with 50 additions and 1 deletions
|
@ -2,6 +2,8 @@ import { app, BrowserWindow } from 'electron';
|
||||||
import { createMainWindow } from "./mainWindow";
|
import { createMainWindow } from "./mainWindow";
|
||||||
import { createSplashWindow } from "./splash";
|
import { createSplashWindow } from "./splash";
|
||||||
|
|
||||||
|
import "./ipc";
|
||||||
|
|
||||||
function createWindows() {
|
function createWindows() {
|
||||||
const mainWindow = createMainWindow();
|
const mainWindow = createMainWindow();
|
||||||
const splash = createSplashWindow();
|
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;
|
||||||
|
}
|
|
@ -1 +1,18 @@
|
||||||
console.log("banana");
|
import { ipcRenderer, webFrame } from "electron";
|
||||||
|
import { GET_VENCORD } from "../shared/IpcEvents";
|
||||||
|
|
||||||
|
const { js, css } = ipcRenderer.sendSync(GET_VENCORD);
|
||||||
|
|
||||||
|
webFrame.executeJavaScript(js);
|
||||||
|
|
||||||
|
const style = document.createElement("style");
|
||||||
|
style.id = "vencord-css-core";
|
||||||
|
style.textContent = css;
|
||||||
|
|
||||||
|
if (document.readyState === "complete") {
|
||||||
|
document.documentElement.appendChild(style);
|
||||||
|
} else {
|
||||||
|
document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(style), {
|
||||||
|
once: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
1
src/shared/IpcEvents.ts
Normal file
1
src/shared/IpcEvents.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export const GET_VENCORD = "VCDGetVencord";
|
Loading…
Add table
Reference in a new issue