diff --git a/browser/background.js b/browser/background.js deleted file mode 100644 index 1f2d5ec17..000000000 --- a/browser/background.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @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 3cac9450a..a6feada7e 100644 --- a/browser/manifestv2.json +++ b/browser/manifestv2.json @@ -26,11 +26,7 @@ } ], - "background": { - "scripts": ["background.js"] - }, - - "web_accessible_resources": ["dist/Vencord.js", "dist/Vencord.css"], + "web_accessible_resources": ["dist/*", "third-party/*"], "browser_specific_settings": { "gecko": { diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs index 02e4da0c8..e4eeb53ea 100644 --- a/scripts/build/buildWeb.mjs +++ b/scripts/build/buildWeb.mjs @@ -145,11 +145,11 @@ async function loadDir(dir, basePath = "") { /** * @type {(target: string, files: string[]) => Promise} */ -async function buildExtension(target, files) { +async function buildExtension(target, files, noMonaco = false) { const entries = { "dist/Vencord.js": await readFile("dist/extension.js"), "dist/Vencord.css": await readFile("dist/extension.css"), - ...await loadDir("dist/monaco"), + ...(noMonaco ? {} : await loadDir("dist/monaco")), ...Object.fromEntries(await Promise.all(RnNoiseFiles.map(async file => [`third-party/rnnoise/${file.replace(/^dist\//, "")}`, await readFile(`node_modules/@sapphi-red/web-noise-suppressor/${file}`)] ))), @@ -195,7 +195,7 @@ const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content await Promise.all([ appendCssRuntime, buildExtension("chromium-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"]), - buildExtension("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"]), + buildExtension("firefox-unpacked", ["content.js", "manifestv2.json", "icon.png"], true), ]); Zip.sync.zip("dist/chromium-unpacked").compress().save("dist/extension.zip"); diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index 4ff5be50f..37d06c7c4 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -18,8 +18,10 @@ import { useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; +import { ErrorCard } from "@components/ErrorCard"; import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; +import { IsFirefox } from "@utils/constants"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { showItemInFolder } from "@utils/native"; @@ -249,12 +251,14 @@ function ThemesTab() { > Load missing Themes - + {!IsFirefox && ( + + )} @@ -316,6 +320,15 @@ function ThemesTab() { return ( + {IsFirefox && ( + + Warning + + You are using Firefox. Expect the vast majority of themes to not work. + If this is a problem, use a chromium browser or Discord Desktop / Vesktop. + + + )} )} - + {!IsFirefox && ( + + )} {!IS_WEB && (