Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfkid200444 committed Jun 24, 2024
2 parents 5266b00 + 62afad3 commit 4627353
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
21 changes: 10 additions & 11 deletions browser/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
10 changes: 9 additions & 1 deletion browser/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],

Expand Down
10 changes: 9 additions & 1 deletion browser/manifestv2.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],

Expand Down
7 changes: 7 additions & 0 deletions src/plugins/ignoreActivities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
11 changes: 8 additions & 3 deletions src/utils/web-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 4627353

Please sign in to comment.