diff options
author | Vendicated <vendicated@riseup.net> | 2022-08-29 18:11:44 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-08-29 18:11:44 +0200 |
commit | 876e622f4f61a4aa229ad69782d374335c3d8d6b (patch) | |
tree | 9119371f584f59b4512553d6548bd11fc84b7dcf /src/patcher.ts | |
parent | af498e78291b67377aaf876c84143cdfe7c8b308 (diff) | |
download | Vencord-876e622f4f61a4aa229ad69782d374335c3d8d6b.tar.gz Vencord-876e622f4f61a4aa229ad69782d374335c3d8d6b.tar.bz2 Vencord-876e622f4f61a4aa229ad69782d374335c3d8d6b.zip |
Progress
Diffstat (limited to 'src/patcher.ts')
-rw-r--r-- | src/patcher.ts | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/patcher.ts b/src/patcher.ts index eb45b98..9fe3dd2 100644 --- a/src/patcher.ts +++ b/src/patcher.ts @@ -2,20 +2,21 @@ import electron, { app, BrowserWindowConstructorOptions } from "electron"; import installExt, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer"; import { join } from "path"; +import { initIpc } from './ipcMain'; console.log("[Vencord] Starting up..."); class BrowserWindow extends electron.BrowserWindow { - constructor(options: BrowserWindowConstructorOptions) { if (options?.webPreferences?.preload && options.title) { const original = options.webPreferences.preload; options.webPreferences.preload = join(__dirname, "preload.js"); - process.env.APP_PATH = app.getAppPath(); process.env.DISCORD_PRELOAD = original; - } - super(options); + + super(options); + initIpc(this); + } else super(options); } } Object.assign(BrowserWindow, electron.BrowserWindow); @@ -28,10 +29,11 @@ require.cache[electronPath]!.exports = { BrowserWindow }; -// Patch appSettingsa to force enable devtools +// Patch appSettings to force enable devtools Object.defineProperty(global, "appSettings", { - set: (v) => { + set: (v: typeof global.appSettings) => { v.set("DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING", true); + // @ts-ignore delete global.appSettings; global.appSettings = v; }, @@ -41,20 +43,17 @@ Object.defineProperty(global, "appSettings", { process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); electron.app.whenReady().then(() => { - /* installExt(REACT_DEVELOPER_TOOLS) + installExt(REACT_DEVELOPER_TOOLS) .then(() => console.log("Installed React DevTools")) - .catch((err) => console.error("Failed to install React DevTools", err)); */ + .catch((err) => console.error("Failed to install React DevTools", err)); // Remove CSP electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => { - if (responseHeaders && url.endsWith(".css")) { + if (responseHeaders) { delete responseHeaders["content-security-policy-report-only"]; delete responseHeaders["content-security-policy"]; - // probably makes github raw work? not tested. - responseHeaders["content-type"] = ["text/css"]; - responseHeaders; } - cb({ cancel: false, responseHeaders: responseHeaders }); + cb({ cancel: false, responseHeaders }); }); // Drop science and sentry requests |