migrate from browser bundle to Vencord:#765
This commit is contained in:
parent
4a9b882119
commit
36d4e90113
7 changed files with 8 additions and 48 deletions
|
@ -2,8 +2,11 @@ import { app, BrowserWindow } from 'electron';
|
|||
import { createMainWindow } from "./mainWindow";
|
||||
import { createSplashWindow } from "./splash";
|
||||
|
||||
import { join } from "path";
|
||||
import "./ipc";
|
||||
|
||||
require(join(__dirname, "Vencord/main.js"));
|
||||
|
||||
function createWindows() {
|
||||
const mainWindow = createMainWindow();
|
||||
const splash = createSplashWindow();
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
import { ipcMain } from "electron";
|
||||
import { GET_VENCORD } from "../shared/IpcEvents";
|
||||
import { fetchVencord } from "./vencord";
|
||||
|
||||
ipcMain.on(GET_VENCORD, async e => {
|
||||
e.returnValue = await fetchVencord();
|
||||
});
|
|
@ -6,7 +6,7 @@ export function createMainWindow() {
|
|||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
sandbox: true,
|
||||
sandbox: false,
|
||||
contextIsolation: true,
|
||||
devTools: true,
|
||||
preload: join(__dirname, "preload.js")
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
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,18 +1,3 @@
|
|||
import { ipcRenderer, webFrame } from "electron";
|
||||
import { GET_VENCORD } from "../shared/IpcEvents";
|
||||
import { join } from "path";
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
require(join(__dirname, "Vencord/preload.js"));
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export const GET_VENCORD = "VCDGetVencord";
|
2
src/shared/util.ts
Normal file
2
src/shared/util.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
|
Loading…
Reference in a new issue