diff options
| author | V <vendicated@riseup.net> | 2023-10-09 03:15:43 +0200 |
|---|---|---|
| committer | V <vendicated@riseup.net> | 2023-10-09 03:15:43 +0200 |
| commit | d81302f64c648f9eba0608ca0c9c6801a853f2b1 (patch) | |
| tree | 8c27bc843a8956cef3e295456406ead787d9917b /browser | |
| parent | 390987e4a9d58c4c0eb9d4f6b4101ecf1203ccba (diff) | |
| download | Vencord-d81302f64c648f9eba0608ca0c9c6801a853f2b1.tar.gz Vencord-d81302f64c648f9eba0608ca0c9c6801a853f2b1.tar.bz2 Vencord-d81302f64c648f9eba0608ca0c9c6801a853f2b1.zip | |
Revert mozilla store compliance changes
This reverts commit 97b6699afefe373d510dda5589a0754a4b380153.
Vencord is dropping support for the firefox extension, so these changes
are now obsolete. revert so users can still install the extension
manually and enjoy the full experience
Diffstat (limited to 'browser')
| -rw-r--r-- | browser/background.js | 32 | ||||
| -rw-r--r-- | browser/manifestv2.json | 6 |
2 files changed, 37 insertions, 1 deletions
diff --git a/browser/background.js b/browser/background.js new file mode 100644 index 0000000..1f2d5ec --- /dev/null +++ b/browser/background.js @@ -0,0 +1,32 @@ +/** + * @template T + * @param {T[]} arr + * @param {(v: T) => boolean} predicate + */ +function removeFirst(arr, predicate) { + const idx = arr.findIndex(predicate); + if (idx !== -1) arr.splice(idx, 1); +} + +chrome.webRequest.onHeadersReceived.addListener( + ({ responseHeaders, type, url }) => { + if (!responseHeaders) return; + + if (type === "main_frame") { + // In main frame requests, the CSP needs to be removed to enable fetching of custom css + // as desired by the user + removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-security-policy"); + } else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com/")) { + // Most users will load css from GitHub, but GitHub doesn't set the correct content type, + // so we fix it here + removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type"); + responseHeaders.push({ + name: "Content-Type", + value: "text/css" + }); + } + return { responseHeaders }; + }, + { urls: ["https://raw.githubusercontent.com/*", "*://*.discord.com/*"], types: ["main_frame", "stylesheet"] }, + ["blocking", "responseHeaders"] +); diff --git a/browser/manifestv2.json b/browser/manifestv2.json index a6feada..3cac945 100644 --- a/browser/manifestv2.json +++ b/browser/manifestv2.json @@ -26,7 +26,11 @@ } ], - "web_accessible_resources": ["dist/*", "third-party/*"], + "background": { + "scripts": ["background.js"] + }, + + "web_accessible_resources": ["dist/Vencord.js", "dist/Vencord.css"], "browser_specific_settings": { "gecko": { |
