aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-15 20:56:21 +0200
committerVendicated <vendicated@riseup.net>2022-10-15 20:56:21 +0200
commit9c7b548a9e8dbcf39360d3eb5eef9e5dad29e40b (patch)
treeb0edca6be0f1751b2df9f2ead64784d824b1eec1
parentc8d87da62d752cf7f0a40f70ae141d7ea69a9adc (diff)
downloadVencord-9c7b548a9e8dbcf39360d3eb5eef9e5dad29e40b.tar.gz
Vencord-9c7b548a9e8dbcf39360d3eb5eef9e5dad29e40b.tar.bz2
Vencord-9c7b548a9e8dbcf39360d3eb5eef9e5dad29e40b.zip
BrowserExtension: Disable CSP
-rw-r--r--browser/background.js25
-rw-r--r--browser/manifest.json4
2 files changed, 27 insertions, 2 deletions
diff --git a/browser/background.js b/browser/background.js
index 872134b..b79c94e 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 c01bc44..2988ba9 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"