BrowserExtension: Disable CSP

This commit is contained in:
Vendicated 2022-10-15 20:56:21 +02:00
parent c8d87da62d
commit 9c7b548a9e
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3
2 changed files with 27 additions and 2 deletions

View File

@ -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"]);

View File

@ -22,7 +22,9 @@
}
],
"permissions": [
"*://*.discord.com/*"
"*://*.discord.com/*",
"webRequest",
"webRequestBlocking"
],
"web_accessible_resources": [
"dist/Vencord.js"