From c50895837e26e87ba6f0a40a3029f1d25b6d61ba Mon Sep 17 00:00:00 2001 From: Luka Leer Date: Thu, 29 Feb 2024 01:09:00 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20native=20frame=20to=20pop-out?= =?UTF-8?q?=20windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luka Leer --- injector/src/modules/browserwindow.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/injector/src/modules/browserwindow.js b/injector/src/modules/browserwindow.js index f8618754..8202155a 100644 --- a/injector/src/modules/browserwindow.js +++ b/injector/src/modules/browserwindow.js @@ -23,6 +23,27 @@ class BrowserWindow extends electron.BrowserWindow { super(options); this.__originalPreload = originalPreload; BetterDiscord.setup(this); + + if (typeof(shouldHaveFrame) === "boolean" && shouldHaveFrame) { + // Override the window open handler to force new windows (such as pop-outs) to have frames + this.webContents.on("did-finish-load", () => { + const originalWindowOpenHandler = this.webContents._windowOpenHandler; + + this.webContents.setWindowOpenHandler((details) => { + const originalResponse = originalWindowOpenHandler(details); + originalResponse.overrideBrowserWindowOptions.frame = true; + return originalResponse; + }); + }); + + // Remove the title bar and menu from new windows + this.webContents.on("did-create-window", (window) => { + window.removeMenu(); + window.webContents.insertCSS(`div[class^="titleBar_"], div[class*=" titleBar_"] { + display: none !important; + }`); + }); + } } }