Link Discord connections through the browser instead of a popup (#1159)

Co-authored-by: Vending Machine <vendicated@riseup.net>
This commit is contained in:
Cookie
2025-05-16 13:34:48 -04:00
committed by GitHub
parent b17fef93ba
commit 43a8781492

View File

@@ -50,7 +50,7 @@ export function handleExternalUrl(url: string, protocol?: string): { action: "de
export function makeLinksOpenExternally(win: BrowserWindow) { export function makeLinksOpenExternally(win: BrowserWindow) {
win.webContents.setWindowOpenHandler(({ url, frameName, features }) => { win.webContents.setWindowOpenHandler(({ url, frameName, features }) => {
try { try {
var { protocol, hostname, pathname } = new URL(url); var { protocol, hostname, pathname, searchParams } = new URL(url);
} catch { } catch {
return { action: "deny" }; return { action: "deny" };
} }
@@ -59,8 +59,10 @@ export function makeLinksOpenExternally(win: BrowserWindow) {
return createOrFocusPopup(frameName, features); return createOrFocusPopup(frameName, features);
} }
if (url === "about:blank" || (frameName === "authorize" && DISCORD_HOSTNAMES.includes(hostname))) if (url === "about:blank") return { action: "allow" };
return { action: "allow" };
// Drop the static temp page Discord web loads for the connections popout
if (frameName === "authorize" && searchParams.get("loading") === "true") return { action: "deny" };
return handleExternalUrl(url, protocol); return handleExternalUrl(url, protocol);
}); });