aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-10-09 03:15:43 +0200
committerV <vendicated@riseup.net>2023-10-09 03:15:43 +0200
commitd81302f64c648f9eba0608ca0c9c6801a853f2b1 (patch)
tree8c27bc843a8956cef3e295456406ead787d9917b
parent390987e4a9d58c4c0eb9d4f6b4101ecf1203ccba (diff)
downloadVencord-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
-rw-r--r--browser/background.js32
-rw-r--r--browser/manifestv2.json6
-rw-r--r--scripts/build/buildWeb.mjs6
-rw-r--r--src/components/VencordSettings/ThemesTab.tsx25
-rw-r--r--src/components/VencordSettings/VencordTab.tsx15
-rw-r--r--src/plugins/_core/supportHelper.tsx19
-rw-r--r--src/utils/constants.ts2
7 files changed, 53 insertions, 52 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": {
diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs
index e4eeb53..02e4da0 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<void>}
*/
-async function buildExtension(target, files, noMonaco = false) {
+async function buildExtension(target, files) {
const entries = {
"dist/Vencord.js": await readFile("dist/extension.js"),
"dist/Vencord.css": await readFile("dist/extension.css"),
- ...(noMonaco ? {} : await loadDir("dist/monaco")),
+ ...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", ["content.js", "manifestv2.json", "icon.png"], true),
+ buildExtension("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"]),
]);
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 573f3b9..f19cdcb 100644
--- a/src/components/VencordSettings/ThemesTab.tsx
+++ b/src/components/VencordSettings/ThemesTab.tsx
@@ -18,11 +18,9 @@
import { useSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
-import { ErrorCard } from "@components/ErrorCard";
import { Flex } from "@components/Flex";
import { DeleteIcon } from "@components/Icons";
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";
@@ -251,14 +249,12 @@ function ThemesTab() {
>
Load missing Themes
</Button>
- {!IsFirefox && (
- <Button
- onClick={() => VencordNative.quickCss.openEditor()}
- size={Button.Sizes.SMALL}
- >
- Edit QuickCSS
- </Button>
- )}
+ <Button
+ onClick={() => VencordNative.quickCss.openEditor()}
+ size={Button.Sizes.SMALL}
+ >
+ Edit QuickCSS
+ </Button>
</>
</Card>
@@ -320,15 +316,6 @@ function ThemesTab() {
return (
<SettingsTab title="Themes">
- {IsFirefox && (
- <ErrorCard>
- <Forms.FormTitle tag="h5">Warning</Forms.FormTitle>
- <Forms.FormText>
- 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.
- </Forms.FormText>
- </ErrorCard>
- )}
<TabBar
type="top"
look="brand"
diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx
index 520e4da..a8e9ea5 100644
--- a/src/components/VencordSettings/VencordTab.tsx
+++ b/src/components/VencordSettings/VencordTab.tsx
@@ -21,7 +21,6 @@ import { Settings, useSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
import DonateButton from "@components/DonateButton";
import { ErrorCard } from "@components/ErrorCard";
-import { IsFirefox } from "@utils/constants";
import { Margins } from "@utils/margins";
import { identity } from "@utils/misc";
import { relaunch, showItemInFolder } from "@utils/native";
@@ -110,14 +109,12 @@ function VencordSettings() {
Restart Client
</Button>
)}
- {!IsFirefox && (
- <Button
- onClick={() => VencordNative.quickCss.openEditor()}
- size={Button.Sizes.SMALL}
- disabled={settingsDir === "Loading..."}>
- Open QuickCSS File
- </Button>
- )}
+ <Button
+ onClick={() => VencordNative.quickCss.openEditor()}
+ size={Button.Sizes.SMALL}
+ disabled={settingsDir === "Loading..."}>
+ Open QuickCSS File
+ </Button>
{!IS_WEB && (
<Button
onClick={() => showItemInFolder(settingsDir)}
diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx
index 2e86869..674be8e 100644
--- a/src/plugins/_core/supportHelper.tsx
+++ b/src/plugins/_core/supportHelper.tsx
@@ -17,7 +17,7 @@
*/
import { DataStore } from "@api/index";
-import { Devs, IsFirefox, SUPPORT_CHANNEL_ID } from "@utils/constants";
+import { Devs, SUPPORT_CHANNEL_ID } from "@utils/constants";
import { isPluginDev } from "@utils/misc";
import { makeCodeblock } from "@utils/text";
import definePlugin from "@utils/types";
@@ -30,7 +30,6 @@ import plugins from "~plugins";
import settings from "./settings";
const REMEMBER_DISMISS_KEY = "Vencord-SupportHelper-Dismiss";
-const FIREFOX_DISMISS_KEY = "Vencord-Firefox-Warning-Dismiss";
const AllowedChannelIds = [
SUPPORT_CHANNEL_ID,
@@ -116,22 +115,6 @@ ${makeCodeblock(enabledPlugins.join(", ") + "\n\n" + enabledApiPlugins.join(", "
onConfirm: rememberDismiss
});
}
-
- if (IsFirefox) {
- const rememberDismiss = () => DataStore.set(FIREFOX_DISMISS_KEY, true);
-
- Alerts.show({
- title: "Hold on!",
- body: <div>
- <Forms.FormText>You are using Firefox.</Forms.FormText>
- <Forms.FormText>Due to Firefox's stupid extension guidelines, most themes and many plugins will not function correctly.</Forms.FormText>
- <Forms.FormText>Do not report bugs. Do not ask for help with broken plugins.</Forms.FormText>
- <Forms.FormText>Instead, use a chromium browser, Discord Desktop, or Vesktop.</Forms.FormText>
- </div>,
- onCancel: rememberDismiss,
- onConfirm: rememberDismiss
- });
- }
}
}
});
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index e80298d..6395ddf 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -389,5 +389,3 @@ export const DevsById = /* #__PURE__*/ (() =>
.map(([_, v]) => [v.id, v] as const)
))
)() as Record<string, Dev>;
-
-export const IsFirefox = IS_EXTENSION && navigator.userAgent.toLowerCase().includes("firefox");