diff --git a/browser/background.js b/browser/background.js index 872134b7..b79c94e2 100644 --- a/browser/background.js +++ b/browser/background.js @@ -1 +1,24 @@ -// could use this in the future +if (typeof browser === "undefined") { + var browser = chrome; +} + +browser.webRequest.onHeadersReceived.addListener(({ responseHeaders, url }) => { + const cspIdx = responseHeaders.findIndex(h => h.name === "content-security-policy"); + if (cspIdx !== -1) + responseHeaders.splice(cspIdx, 1); + + if (url.endsWith(".css")) { + const contentType = responseHeaders.find(h => h.name === "content-type"); + if (contentType) + contentType.value = "text/css"; + else + responseHeaders.push({ + name: "content-type", + value: "text/json" + }); + } + + return { + responseHeaders + }; +}, { urls: ["*://*.discord.com/*"] }, ["blocking", "responseHeaders"]); diff --git a/browser/manifest.json b/browser/manifest.json index c01bc449..2988ba9d 100644 --- a/browser/manifest.json +++ b/browser/manifest.json @@ -22,7 +22,9 @@ } ], "permissions": [ - "*://*.discord.com/*" + "*://*.discord.com/*", + "webRequest", + "webRequestBlocking" ], "web_accessible_resources": [ "dist/Vencord.js"