diff --git a/browser/content.js b/browser/content.js index 4810fe3c8..57964af64 100644 --- a/browser/content.js +++ b/browser/content.js @@ -2,23 +2,22 @@ if (typeof browser === "undefined") { var browser = chrome; } -const script = document.createElement("script"); -script.src = browser.runtime.getURL("dist/Vencord.js"); -script.id = "vencord-script"; -Object.assign(script.dataset, { - extensionBaseUrl: browser.runtime.getURL(""), - version: browser.runtime.getManifest().version -}); - const style = document.createElement("link"); style.type = "text/css"; style.rel = "stylesheet"; style.href = browser.runtime.getURL("dist/Vencord.css"); -document.documentElement.append(script); - document.addEventListener( "DOMContentLoaded", - () => document.documentElement.append(style), + () => { + document.documentElement.append(style); + window.postMessage({ + type: "vencord:meta", + meta: { + EXTENSION_VERSION: browser.runtime.getManifest().version, + EXTENSION_BASE_URL: browser.runtime.getURL(""), + } + }); + }, { once: true } ); diff --git a/browser/manifest.json b/browser/manifest.json index 69bf0cec0..c527c75b8 100644 --- a/browser/manifest.json +++ b/browser/manifest.json @@ -22,7 +22,15 @@ "run_at": "document_start", "matches": ["*://*.discord.com/*"], "js": ["content.js"], - "all_frames": true + "all_frames": true, + "world": "ISOLATED" + }, + { + "run_at": "document_start", + "matches": ["*://*.discord.com/*"], + "js": ["dist/Vencord.js"], + "all_frames": true, + "world": "MAIN" } ], diff --git a/browser/manifestv2.json b/browser/manifestv2.json index 3cac9450a..f5b08571a 100644 --- a/browser/manifestv2.json +++ b/browser/manifestv2.json @@ -22,7 +22,15 @@ "run_at": "document_start", "matches": ["*://*.discord.com/*"], "js": ["content.js"], - "all_frames": true + "all_frames": true, + "world": "ISOLATED" + }, + { + "run_at": "document_start", + "matches": ["*://*.discord.com/*"], + "js": ["dist/Vencord.js"], + "all_frames": true, + "world": "MAIN" } ], diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 78c1c5cf8..bab69d89b 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -222,6 +222,13 @@ export default definePlugin({ } ] }, + { + find: '="ActivityTrackingStore",', + replacement: { + match: /getVisibleRunningGames\(\).+?;(?=for)(?<=(\i)=\i\.\i\.getVisibleRunningGames.+?)/, + replace: (m, runningGames) => `${m}${runningGames}=${runningGames}.filter(({id,name})=>$self.isActivityNotIgnored({type:0,application_id:id,name}));` + } + }, { find: ".Messages.SETTINGS_GAMES_TOGGLE_OVERLAY", replacement: { diff --git a/src/utils/web-metadata.ts b/src/utils/web-metadata.ts index 26409a211..cca07ad4c 100644 --- a/src/utils/web-metadata.ts +++ b/src/utils/web-metadata.ts @@ -8,7 +8,12 @@ export let EXTENSION_BASE_URL: string; export let EXTENSION_VERSION: string; if (IS_EXTENSION) { - const script = document.querySelector("#vencord-script") as HTMLScriptElement; - EXTENSION_BASE_URL = script.dataset.extensionBaseUrl!; - EXTENSION_VERSION = script.dataset.version!; + const listener = (e: MessageEvent) => { + if (e.data?.type === "vencord:meta") { + ({ EXTENSION_BASE_URL, EXTENSION_VERSION } = e.data.meta); + window.removeEventListener("message", listener); + } + }; + + window.addEventListener("message", listener); }