Skip to content

Commit

Permalink
Vencord compatibility (reload bug exists)
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeAspy committed Sep 14, 2024
1 parent f3b85fd commit da80b8b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: SomeAspy
7 changes: 7 additions & 0 deletions src/main/functions/fetchMods.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {app} from "electron";
import {writeFileSync} from "fs";
import {join} from "path";
import {getConfig} from "../../shared/config.js";

async function fetchMod(fileName: string, url: string) {
try {
Expand All @@ -21,4 +22,10 @@ async function fetchMod(fileName: string, url: string) {
export async function fetchMods() {
console.log("[FetchMods]: Fetching Shelter");
await fetchMod("shelter.js", "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.js");

if (getConfig("mods").includes("vencord")) {
console.log("[FetchMods]: Fetching Vencord");
await fetchMod("vencord.js", "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js");
await fetchMod("vencord.css", "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.css");
}
}
9 changes: 9 additions & 0 deletions src/main/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import {app, ipcMain} from "electron";
import {readFileSync} from "fs";
import {join} from "path";
import {getConfig} from "../shared/config.js";

ipcMain.handle("getShelter", () => {
return readFileSync(join(app.getPath("userData"), "shelter.js"), {encoding: "utf8"});
});

ipcMain.handle("getVencord", () => {
return {
js: readFileSync(join(app.getPath("userData"), "vencord.js"), {encoding: "utf8"}),
css: readFileSync(join(app.getPath("userData"), "vencord.css"), {encoding: "utf8"}),
enabled: getConfig("mods").includes("vencord")
};
});
1 change: 1 addition & 0 deletions src/main/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import {app} from "electron";
import {getConfig} from "../shared/config.js";

app.setPath("sessionData", `${app.getPath("userData")}/sessionData`);

getConfig("fileExistsDoNotTouch");
1 change: 1 addition & 0 deletions src/main/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {app, Menu, nativeImage, Tray, type WebContents} from "electron";
import icon from "../../resources/placeholderTrayIcon.png?asset";

export function startTray(pageData: WebContents) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const tray = new Tray(icon as string);
tray.setToolTip("Acorn");
tray.setContextMenu(
Expand Down
2 changes: 1 addition & 1 deletion src/preload/mods/shelter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ try {
await webFrame.executeJavaScript(shelter);
});
} catch (error) {
console.error(error)
console.error(error);
}
12 changes: 12 additions & 0 deletions src/preload/mods/vencord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {ipcRenderer, webFrame} from "electron";

try {
await ipcRenderer.invoke("getVencord").then(async (data: {js: string; css: string; enabled: boolean}) => {
if (data.enabled) {
await webFrame.executeJavaScript(data.js);
webFrame.insertCSS(data.css);
}
});
} catch (error) {
console.error(error);
}
3 changes: 2 additions & 1 deletion src/preload/preload.mts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import "./mods/shelter.js"
import "./mods/shelter.js";
import "./mods/vencord.js";

0 comments on commit da80b8b

Please sign in to comment.