diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 5964dfa..b22301b 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -1,7 +1,8 @@ import { app, ipcMain, shell } from "electron"; import { readFileSync } from "fs"; +import { readFile } from "fs/promises"; import { join } from "path"; -import { FOCUS, GET_RENDERER_SCRIPT, GET_SETTINGS, GET_VENCORD_PRELOAD_FILE, RELAUNCH, SET_SETTINGS, SHOW_ITEM_IN_FOLDER } from "../shared/IpcEvents"; +import { FOCUS, GET_RENDERER_SCRIPT, GET_RENDERER_STYLES, GET_SETTINGS, GET_VENCORD_PRELOAD_FILE, RELAUNCH, SET_SETTINGS, SHOW_ITEM_IN_FOLDER } from "../shared/IpcEvents"; import { VENCORD_FILES_DIR } from "./constants"; import { mainWin } from "./mainWindow"; import { PlainSettings, setSettings } from "./settings"; @@ -14,6 +15,8 @@ ipcMain.on(GET_RENDERER_SCRIPT, e => { e.returnValue = readFileSync(join(__dirname, "renderer.js"), "utf-8"); }); +ipcMain.handle(GET_RENDERER_STYLES, () => readFile(join(__dirname, "renderer.css"), "utf-8")); + ipcMain.on(GET_SETTINGS, e => { e.returnValue = PlainSettings; }); diff --git a/src/preload/index.ts b/src/preload/index.ts index 3df5a9a..300e0fc 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -1,5 +1,5 @@ import { contextBridge, ipcRenderer, webFrame } from "electron"; -import { GET_RENDERER_SCRIPT, GET_VENCORD_PRELOAD_FILE } from "../shared/IpcEvents"; +import { GET_RENDERER_SCRIPT, GET_RENDERER_STYLES, GET_VENCORD_PRELOAD_FILE } from "../shared/IpcEvents"; import { VencordDesktop } from "./VencordDesktop"; contextBridge.exposeInMainWorld("VencordDesktop", VencordDesktop); @@ -7,3 +7,4 @@ contextBridge.exposeInMainWorld("VencordDesktop", VencordDesktop); require(ipcRenderer.sendSync(GET_VENCORD_PRELOAD_FILE)); webFrame.executeJavaScript(ipcRenderer.sendSync(GET_RENDERER_SCRIPT)); +ipcRenderer.invoke(GET_RENDERER_STYLES).then(s => webFrame.insertCSS(s)); diff --git a/src/renderer/fixes.ts b/src/renderer/fixes.ts index 0e6f67b..74ab353 100644 --- a/src/renderer/fixes.ts +++ b/src/renderer/fixes.ts @@ -1,3 +1,5 @@ +import "./hideGarbage.css"; + // Make clicking Notifications focus the window const originalSetOnClick = Object.getOwnPropertyDescriptor(Notification.prototype, "onclick")!.set!; Object.defineProperty(Notification.prototype, "onclick", { diff --git a/src/renderer/hideGarbage.css b/src/renderer/hideGarbage.css new file mode 100644 index 0000000..a820403 --- /dev/null +++ b/src/renderer/hideGarbage.css @@ -0,0 +1,5 @@ +/* Download Desktop button in guilds list */ +[class|=listItem]:has([data-list-item-id=guildsnav___app-download-button]), +[class|=listItem]:has(+ [class|=listItem] [data-list-item-id=guildsnav___app-download-button]) { + display: none; +} diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index c3a1530..b87a5fa 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -1,7 +1,10 @@ export const GET_VENCORD_PRELOAD_FILE = "VCD_GET_VC_PRELOAD_FILE"; export const GET_RENDERER_SCRIPT = "VCD_GET_RENDERER_SCRIPT"; +export const GET_RENDERER_STYLES = "VCD_GET_RENDERER_STYLES"; + export const RELAUNCH = "VCD_RELAUNCH"; +export const FOCUS = "VC_FOCUS"; + export const SHOW_ITEM_IN_FOLDER = "VCD_SHOW_ITEM_IN_FOLDER"; export const GET_SETTINGS = "VCD_GET_SETTINGS"; export const SET_SETTINGS = "VCD_SET_SETTINGS"; -export const FOCUS = "VC_FOCUS";