Add about page & setting to open links with electron

This commit is contained in:
Vendicated
2023-04-05 17:55:49 +02:00
parent 17150503d2
commit 1980606e03
6 changed files with 93 additions and 32 deletions

View File

@@ -0,0 +1,32 @@
import { BrowserWindow, shell } from "electron";
import { Settings } from "../settings";
export function makeLinksOpenExternally(win: BrowserWindow) {
win.webContents.setWindowOpenHandler(({ url }) => {
switch (url) {
case "about:blank":
case "https://discord.com/popout":
return { action: "allow" };
}
try {
var protocol = new URL(url).protocol;
} catch {
return { action: "deny" };
}
switch (protocol) {
case "http:":
case "https:":
if (Settings.openLinksWithElectron) {
return { action: "allow" };
}
case "mailto:":
case "steam:":
case "spotify:":
shell.openExternal(url);
}
return { action: "deny" };
});
}