aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--.github/workflows/publish.yml5
-rw-r--r--browser/background.js32
-rw-r--r--browser/manifestv2.json41
-rw-r--r--package.json2
-rw-r--r--scripts/build/buildWeb.mjs3
6 files changed, 79 insertions, 6 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 28a460e..46645ad 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -42,7 +42,7 @@ jobs:
- name: Clean up obsolete files
run: |
- rm -rf dist/extension-unpacked Vencord.user.css vencordDesktopRenderer.css vencordDesktopRenderer.css.map
+ rm -rf dist/*-unpacked Vencord.user.css vencordDesktopRenderer.css vencordDesktopRenderer.css.map
- name: Get some values needed for the release
id: release_values
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 89cc2cb..9f9df49 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -35,15 +35,15 @@ jobs:
- name: Publish extension
run: |
- cd dist/extension-unpacked
-
# Do not fail so that even if chrome fails, firefox gets a shot. But also store exit code to fail workflow later
EXIT_CODE=0
# Chrome
+ cd dist/chromium-unpacked
pnpx chrome-webstore-upload-cli@2.1.0 upload --auto-publish || EXIT_CODE=$?
# Firefox
+ cd ../chromium-unpacked
npm i -g web-ext@7.4.0 web-ext-submit@7.4.0
web-ext-submit || EXIT_CODE=$?
@@ -58,4 +58,3 @@ jobs:
# Firefox
WEB_EXT_API_KEY: ${{ secrets.WEBEXT_USER }}
WEB_EXT_API_SECRET: ${{ secrets.WEBEXT_SECRET }}
-
diff --git a/browser/background.js b/browser/background.js
new file mode 100644
index 0000000..7fc4a82
--- /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
new file mode 100644
index 0000000..3cac945
--- /dev/null
+++ b/browser/manifestv2.json
@@ -0,0 +1,41 @@
+{
+ "manifest_version": 2,
+ "minimum_chrome_version": "91",
+
+ "name": "Vencord Web",
+ "description": "The cutest Discord mod now in your browser",
+ "author": "Vendicated",
+ "homepage_url": "https://github.com/Vendicated/Vencord",
+ "icons": {
+ "128": "icon.png"
+ },
+
+ "permissions": [
+ "webRequest",
+ "webRequestBlocking",
+ "*://*.discord.com/*",
+ "https://raw.githubusercontent.com/*"
+ ],
+
+ "content_scripts": [
+ {
+ "run_at": "document_start",
+ "matches": ["*://*.discord.com/*"],
+ "js": ["content.js"],
+ "all_frames": true
+ }
+ ],
+
+ "background": {
+ "scripts": ["background.js"]
+ },
+
+ "web_accessible_resources": ["dist/Vencord.js", "dist/Vencord.css"],
+
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "vencord-firefox@vendicated.dev",
+ "strict_min_version": "91.0"
+ }
+ }
+}
diff --git a/package.json b/package.json
index cf08488..b08a243 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
- "version": "1.1.7",
+ "version": "1.1.8",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {
diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs
index 98d56b0..cc27ea8 100644
--- a/scripts/build/buildWeb.mjs
+++ b/scripts/build/buildWeb.mjs
@@ -142,6 +142,7 @@ const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content
await Promise.all([
appendCssRuntime,
buildPluginZip("extension.zip", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], true),
- buildPluginZip("extension-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], false),
+ buildPluginZip("chromium-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], false),
+ buildPluginZip("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"], false),
]);