-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnative.ts
35 lines (32 loc) · 1.11 KB
/
native.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { exec } from "child_process";
import { IpcMainInvokeEvent } from "electron";
export async function openIncognitoLink(_:IpcMainInvokeEvent, url: string, preferredBrowser?:string, customCommand?:string) {
if (!preferredBrowser) {
preferredBrowser = "chrome";
}
switch (preferredBrowser) {
case "chrome":
exec(`chrome --incognito ${url}`);
return;
case "firefox":
exec(`firefox -private ${url}`);
return;
case "edge":
exec(`msedge --inprivate ${url}`);
return;
case "custom":
if (!customCommand) {
_.sender.executeJavaScript("console.error('No custom command set for opening links')");
return;
}
exec(customCommand.replace("%url%", url));
return;
default:
_.sender.executeJavaScript("console.error('IncognitoLinks: Unknown browser: " + preferredBrowser + "')");
}
}