aboutsummaryrefslogtreecommitdiff
path: root/src/patcher.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/patcher.ts')
-rw-r--r--src/patcher.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/patcher.ts b/src/patcher.ts
index ba906d5..89c636c 100644
--- a/src/patcher.ts
+++ b/src/patcher.ts
@@ -17,7 +17,7 @@
*/
import { onceDefined } from "@utils/onceDefined";
-import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron";
+import electron, { app, BrowserWindowConstructorOptions, Menu, protocol, session } from "electron";
import { dirname, join } from "path";
import { initIpc } from "./ipcMain";
@@ -118,10 +118,10 @@ if (!process.argv.includes("--vanilla")) {
process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
- electron.app.whenReady().then(() => {
+ app.whenReady().then(() => {
// Source Maps! Maybe there's a better way but since the renderer is executed
// from a string I don't think any other form of sourcemaps would work
- electron.protocol.registerFileProtocol("vencord", ({ url: unsafeUrl }, cb) => {
+ protocol.registerFileProtocol("vencord", ({ url: unsafeUrl }, cb) => {
let url = unsafeUrl.slice("vencord://".length);
if (url.endsWith("/")) url = url.slice(0, -1);
switch (url) {
@@ -177,7 +177,7 @@ if (!process.argv.includes("--vanilla")) {
}
}
- electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, resourceType }, cb) => {
+ session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, resourceType }, cb) => {
if (responseHeaders) {
if (resourceType === "mainFrame")
patchCsp(responseHeaders, "content-security-policy");
@@ -189,6 +189,11 @@ if (!process.argv.includes("--vanilla")) {
}
cb({ cancel: false, responseHeaders });
});
+
+ // assign a noop to onHeadersReceived to prevent other mods from adding their own incompatible ones.
+ // For instance, OpenAsar adds their own that doesn't fix content-type for stylesheets which makes it
+ // impossible to load css from github raw despite our fix above
+ session.defaultSession.webRequest.onHeadersReceived = () => { };
});
} else {
console.log("[Vencord] Running in vanilla mode. Not loading Vencord");