aboutsummaryrefslogtreecommitdiff
path: root/src/patcher.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-03-31 01:18:57 +0200
committerVendicated <vendicated@riseup.net>2023-03-31 01:18:57 +0200
commitff16513f217bd55920e0a26ca24c7c5cf7f4b270 (patch)
tree9bb91157a9a500c0a648690923fcead936746a5a /src/patcher.ts
parent906c265aea19c3e25a1d9ddb49d11e3d341f50c4 (diff)
downloadVencord-ff16513f217bd55920e0a26ca24c7c5cf7f4b270.tar.gz
Vencord-ff16513f217bd55920e0a26ca24c7c5cf7f4b270.tar.bz2
Vencord-ff16513f217bd55920e0a26ca24c7c5cf7f4b270.zip
Fix onHeadersReceived clashes when using OpenAsar (fix github raw styles)
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");