aboutsummaryrefslogtreecommitdiff
path: root/src/patcher.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-11 21:48:28 +0200
committerVendicated <vendicated@riseup.net>2022-10-11 21:48:28 +0200
commit86eacea74d754f67e660f3ea7fd988a2444ea3cf (patch)
treeeed2a4eb4b5feee0eca9c9ef88d525c8c56080d2 /src/patcher.ts
parent516f8c488ab70519361e5732546ac579c56ef3ab (diff)
downloadVencord-86eacea74d754f67e660f3ea7fd988a2444ea3cf.tar.gz
Vencord-86eacea74d754f67e660f3ea7fd988a2444ea3cf.tar.bz2
Vencord-86eacea74d754f67e660f3ea7fd988a2444ea3cf.zip
Make ReactDevTools Opt-in
Diffstat (limited to 'src/patcher.ts')
-rw-r--r--src/patcher.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/patcher.ts b/src/patcher.ts
index bb7aab2..2725b03 100644
--- a/src/patcher.ts
+++ b/src/patcher.ts
@@ -1,7 +1,7 @@
import electron, { app, BrowserWindowConstructorOptions } from "electron";
-import installExt, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer";
import { join } from "path";
import { initIpc } from "./ipcMain";
+import { readSettings } from "./ipcMain/index";
console.log("[Vencord] Starting up...");
@@ -47,9 +47,17 @@ Object.defineProperty(global, "appSettings", {
process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
electron.app.whenReady().then(() => {
- installExt(REACT_DEVELOPER_TOOLS)
- .then(() => console.info("Installed React DevTools"))
- .catch(err => console.error("Failed to install React DevTools", err));
+ try {
+ const settings = JSON.parse(readSettings());
+ if (settings.enableReactDevtools)
+ import("electron-devtools-installer")
+ .then(({ default: inst, REACT_DEVELOPER_TOOLS }) =>
+ // @ts-ignore: cursed fake esm turns it into exports.default.default
+ (inst.default ?? inst)(REACT_DEVELOPER_TOOLS)
+ )
+ .then(() => console.info("[Vencord] Installed React Developer Tools"))
+ .catch(err => console.error("[Vencord] Failed to install React Developer Tools", err));
+ } catch { }
// Remove CSP
electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => {