Progress
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user