diff --git a/src/main/utils/makeLinksOpenExternally.ts b/src/main/utils/makeLinksOpenExternally.ts index 5197261..c58bad1 100644 --- a/src/main/utils/makeLinksOpenExternally.ts +++ b/src/main/utils/makeLinksOpenExternally.ts @@ -9,20 +9,22 @@ import { BrowserWindow, shell } from "electron"; import { Settings } from "../settings"; import { execSteamURL, isDeckGameMode, steamOpenURL } from "./steamOS"; +const DISCORD_HOSTNAMES = ["discord.com", "canary.discord.com", "ptb.discord.com"]; export function makeLinksOpenExternally(win: BrowserWindow) { - win.webContents.setWindowOpenHandler(({ url }) => { - switch (url) { - case "about:blank": - case "https://discord.com/popout": - return { action: "allow" }; - } - + win.webContents.setWindowOpenHandler(({ url, frameName }) => { try { - var { protocol } = new URL(url); + var { protocol, hostname, pathname } = new URL(url); } catch { return { action: "deny" }; } + if ( + url === "about:blank" || + (pathname === "/popout" && DISCORD_HOSTNAMES.includes(hostname)) || + (frameName === "authorize" && DISCORD_HOSTNAMES.includes(hostname)) + ) + return { action: "allow" }; + switch (protocol) { case "http:": case "https:":