aboutsummaryrefslogtreecommitdiff
path: root/browser/background.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/background.js')
-rw-r--r--browser/background.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/browser/background.js b/browser/background.js
new file mode 100644
index 0000000..9c5ed96
--- /dev/null
+++ b/browser/background.js
@@ -0,0 +1,28 @@
+
+function setContentTypeOnStylesheets(details) {
+ if (details.type === 'stylesheet') {
+ details.responseHeaders.push({name: 'Content-Type', value: 'text/css'})
+ }
+ return {responseHeaders: details.responseHeaders }
+}
+
+var cspHeaders = [
+ 'content-security-policy',
+ 'content-security-policy-report-only',
+]
+
+function removeCSPHeaders(details) {
+ return {responseHeaders: details.responseHeaders.filter(header =>
+ !cspHeaders.includes(header.name.toLowerCase()))}
+}
+
+
+
+
+browser.webRequest.onHeadersReceived.addListener(
+ setContentTypeOnStylesheets, {urls: ["https://raw.githubusercontent.com/*"]}, ['blocking']
+)
+
+browser.webRequest.onHeadersReceived.addListener(
+ removeCSPHeaders, {urls: ["https://raw.githubusercontent.com/*", "*://*.discord.com/*"]}, ['blocking', 'responseHeaders']
+)