From e3e5da10a9a3d637ba73017809f36501fff02cda Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Thu, 19 Oct 2023 05:44:29 +0800 Subject: [PATCH 001/128] fix: Content Security Policy patching (#1814) Co-authored-by: Vendicated --- src/main/index.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index d1b7c5d97..481736a98 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -62,6 +62,10 @@ if (IS_VESKTOP || !IS_VANILLA) { } catch { } + const findHeader = (headers: Record, headerName: Lowercase) => { + return Object.keys(headers).find(h => h.toLowerCase() === headerName); + }; + // Remove CSP type PolicyResult = Record; @@ -73,6 +77,7 @@ if (IS_VESKTOP || !IS_VANILLA) { result[directiveKey] = directiveValue; } }); + return result; }; const stringifyPolicy = (policy: PolicyResult): string => @@ -81,31 +86,39 @@ if (IS_VESKTOP || !IS_VANILLA) { .map(directive => directive.flat().join(" ")) .join("; "); - function patchCsp(headers: Record, header: string) { - if (header in headers) { + const patchCsp = (headers: Record) => { + const header = findHeader(headers, "content-security-policy"); + + if (header) { const csp = parsePolicy(headers[header][0]); for (const directive of ["style-src", "connect-src", "img-src", "font-src", "media-src", "worker-src"]) { - csp[directive] = ["*", "blob:", "data:", "vencord:", "'unsafe-inline'"]; + csp[directive] ??= []; + csp[directive].push("*", "blob:", "data:", "vencord:", "'unsafe-inline'"); } + // TODO: Restrict this to only imported packages with fixed version. // Perhaps auto generate with esbuild csp["script-src"] ??= []; csp["script-src"].push("'unsafe-eval'", "https://unpkg.com", "https://cdnjs.cloudflare.com"); headers[header] = [stringifyPolicy(csp)]; } - } + }; session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, resourceType }, cb) => { if (responseHeaders) { if (resourceType === "mainFrame") - patchCsp(responseHeaders, "content-security-policy"); + patchCsp(responseHeaders); // Fix hosts that don't properly set the css content type, such as // raw.githubusercontent.com - if (resourceType === "stylesheet") - responseHeaders["content-type"] = ["text/css"]; + if (resourceType === "stylesheet") { + const header = findHeader(responseHeaders, "content-type"); + if (header) + responseHeaders[header] = ["text/css"]; + } } + cb({ cancel: false, responseHeaders }); }); From 4f57c7eded1eda58f9c6e98b877a1cda29055117 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Thu, 19 Oct 2023 04:54:35 +0700 Subject: [PATCH 002/128] betterNotes, userVoiceShow: fix padding issue (#1804) --- .../betterNotes/{index.ts => index.tsx} | 20 ++++++++++++++++++- .../components/VoiceChannelSection.css | 7 ++++--- src/plugins/userVoiceShow/index.tsx | 5 ++--- 3 files changed, 25 insertions(+), 7 deletions(-) rename src/plugins/betterNotes/{index.ts => index.tsx} (79%) diff --git a/src/plugins/betterNotes/index.ts b/src/plugins/betterNotes/index.tsx similarity index 79% rename from src/plugins/betterNotes/index.ts rename to src/plugins/betterNotes/index.tsx index d9c5b45c3..06c735504 100644 --- a/src/plugins/betterNotes/index.ts +++ b/src/plugins/betterNotes/index.tsx @@ -19,6 +19,9 @@ import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; + +const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection"); export default definePlugin({ name: "BetterNotesBox", @@ -34,12 +37,20 @@ export default definePlugin({ match: /hideNote:.+?(?=[,}])/g, replace: "hideNote:true", } - }, { + }, + { find: "Messages.NOTE_PLACEHOLDER", replacement: { match: /\.NOTE_PLACEHOLDER,/, replace: "$&spellCheck:!Vencord.Settings.plugins.BetterNotesBox.noSpellCheck," } + }, + { + find: ".Messages.NOTE}", + replacement: { + match: /(\i)\.hideNote\?null/, + replace: "$1.hideNote?$self.patchPadding($1)" + } } ], @@ -56,5 +67,12 @@ export default definePlugin({ disabled: () => Settings.plugins.BetterNotesBox.hide, default: false } + }, + + patchPadding(e: any) { + if (!e.lastSection) return; + return ( +
+ ); } }); diff --git a/src/plugins/userVoiceShow/components/VoiceChannelSection.css b/src/plugins/userVoiceShow/components/VoiceChannelSection.css index 0cf8701fc..00ecf5d41 100644 --- a/src/plugins/userVoiceShow/components/VoiceChannelSection.css +++ b/src/plugins/userVoiceShow/components/VoiceChannelSection.css @@ -1,4 +1,4 @@ -.vc-uvs-button > div { +.vc-uvs-button>div { white-space: normal !important; } @@ -21,6 +21,7 @@ margin-bottom: 0 !important; } -.vc-uvs-popout-margin > [class^="section"] { - margin-top: -12px; +.vc-uvs-popout-margin-self>[class^="section"] { + padding-top: 0; + padding-bottom: 12px; } diff --git a/src/plugins/userVoiceShow/index.tsx b/src/plugins/userVoiceShow/index.tsx index 9d8730b80..85c1bedf1 100644 --- a/src/plugins/userVoiceShow/index.tsx +++ b/src/plugins/userVoiceShow/index.tsx @@ -20,14 +20,13 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; +import { findStoreLazy } from "@webpack"; import { ChannelStore, GuildStore, UserStore } from "@webpack/common"; import { User } from "discord-types/general"; import { VoiceChannelSection } from "./components/VoiceChannelSection"; const VoiceStateStore = findStoreLazy("VoiceStateStore"); -const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection"); const settings = definePluginSettings({ showInUserProfileModal: { @@ -88,7 +87,7 @@ export default definePlugin({ patchPopout: ({ user }: UserProps) => { const isSelfUser = user.id === UserStore.getCurrentUser().id; return ( -
+
); From b577660800958ff555b11887654a2f9ba4b6a67b Mon Sep 17 00:00:00 2001 From: Marocco2 Date: Thu, 19 Oct 2023 00:05:47 +0200 Subject: [PATCH 003/128] feat(VcNarrator): add `{{NICKNAME}}` as placeholder (#1792) --- src/plugins/vcNarrator/index.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/plugins/vcNarrator/index.tsx b/src/plugins/vcNarrator/index.tsx index 39dabfc36..ac629e749 100644 --- a/src/plugins/vcNarrator/index.tsx +++ b/src/plugins/vcNarrator/index.tsx @@ -24,7 +24,7 @@ import { Margins } from "@utils/margins"; import { wordsToTitle } from "@utils/text"; import definePlugin, { OptionType, PluginOptionsItem } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { Button, ChannelStore, Forms, SelectedChannelStore, useMemo, UserStore } from "@webpack/common"; +import { Button, ChannelStore, Forms, GuildMemberStore, SelectedChannelStore, SelectedGuildStore, useMemo, UserStore } from "@webpack/common"; interface VoiceState { userId: string; @@ -70,11 +70,12 @@ function clean(str: string) { .trim(); } -function formatText(str: string, user: string, channel: string, displayName: string) { +function formatText(str: string, user: string, channel: string, displayName: string, nickname: string) { return str .replaceAll("{{USER}}", clean(user) || (user ? "Someone" : "")) .replaceAll("{{CHANNEL}}", clean(channel) || "channel") - .replaceAll("{{DISPLAY_NAME}}", clean(displayName) || (displayName ? "Someone" : "")); + .replaceAll("{{DISPLAY_NAME}}", clean(displayName) || (displayName ? "Someone" : "")) + .replaceAll("{{NICKNAME}}", clean(nickname) || (nickname ? "Someone" : "")); } /* @@ -145,8 +146,9 @@ function updateStatuses(type: string, { deaf, mute, selfDeaf, selfMute, userId, function playSample(tempSettings: any, type: string) { const settings = Object.assign({}, Settings.plugins.VcNarrator, tempSettings); const currentUser = UserStore.getCurrentUser(); + const myGuildId = SelectedGuildStore.getGuildId(); - speak(formatText(settings[type + "Message"], currentUser.username, "general", (currentUser as any).globalName ?? currentUser.username), settings); + speak(formatText(settings[type + "Message"], currentUser.username, "general", (currentUser as any).globalName ?? currentUser.username, GuildMemberStore.getNick(myGuildId, currentUser.id) ?? currentUser.username), settings); } export default definePlugin({ @@ -156,6 +158,7 @@ export default definePlugin({ flux: { VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) { + const myGuildId = SelectedGuildStore.getGuildId(); const myChanId = SelectedChannelStore.getVoiceChannelId(); const myId = UserStore.getCurrentUser().id; @@ -175,9 +178,10 @@ export default definePlugin({ const template = Settings.plugins.VcNarrator[type + "Message"]; const user = isMe && !Settings.plugins.VcNarrator.sayOwnName ? "" : UserStore.getUser(userId).username; const displayName = user && ((UserStore.getUser(userId) as any).globalName ?? user); + const nickname = user && (GuildMemberStore.getNick(myGuildId, userId) ?? user); const channel = ChannelStore.getChannel(id).name; - speak(formatText(template, user, channel, displayName)); + speak(formatText(template, user, channel, displayName, nickname)); // updateStatuses(type, state, isMe); } @@ -189,7 +193,7 @@ export default definePlugin({ if (!s) return; const event = s.mute || s.selfMute ? "unmute" : "mute"; - speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name, "")); + speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name, "", "")); }, AUDIO_TOGGLE_SELF_DEAF() { @@ -198,7 +202,7 @@ export default definePlugin({ if (!s) return; const event = s.deaf || s.selfDeaf ? "undeafen" : "deafen"; - speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name, "")); + speak(formatText(Settings.plugins.VcNarrator[event + "Message"], "", ChannelStore.getChannel(chanId).name, "", "")); } }, @@ -315,8 +319,8 @@ export default definePlugin({ You can customise the spoken messages below. You can disable specific messages by setting them to nothing - The special placeholders {"{{USER}}"}, {"{{DISPLAY_NAME}}"} and {"{{CHANNEL}}"}{" "} - will be replaced with the user's name (nothing if it's yourself), the user's display name and the channel's name respectively + The special placeholders {"{{USER}}"}, {"{{DISPLAY_NAME}}"}, {"{{NICKNAME}}"} and {"{{CHANNEL}}"}{" "} + will be replaced with the user's name (nothing if it's yourself), the user's display name, the user's nickname on current server and the channel's name respectively {hasEnglishVoices && ( <> From a452945ac899feca7d8c11add91d3a23b5ccb59d Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Thu, 19 Oct 2023 05:14:14 +0700 Subject: [PATCH 004/128] feat(plugin): NoTypingAnimation (#1680) --- src/plugins/noTypingAnimation/index.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/plugins/noTypingAnimation/index.ts diff --git a/src/plugins/noTypingAnimation/index.ts b/src/plugins/noTypingAnimation/index.ts new file mode 100644 index 000000000..d4aab9004 --- /dev/null +++ b/src/plugins/noTypingAnimation/index.ts @@ -0,0 +1,21 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "NoTypingAnimation", + authors: [Devs.AutumnVN], + description: "Disables the CPU-intensive typing dots animation", + patches: [{ + find: "dotCycle", + replacement: { + match: /document.hasFocus\(\)/, + replace: "false" + } + }] +}); From cd613549983adcb0cc632c110e34739ee7270edf Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 19 Oct 2023 00:22:49 +0200 Subject: [PATCH 005/128] ContributorModal: Fix vertical overflow on multi word names --- src/components/PluginSettings/contributorModal.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/PluginSettings/contributorModal.css b/src/components/PluginSettings/contributorModal.css index a8af8c8b8..09f0103fd 100644 --- a/src/components/PluginSettings/contributorModal.css +++ b/src/components/PluginSettings/contributorModal.css @@ -17,6 +17,7 @@ font-size: 20px; height: 20px; position: relative; + text-wrap: nowrap; } .vc-author-modal-name::before { From 5d7ede34d811d56e2b2c845dd940471e3674a616 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 19 Oct 2023 01:23:59 +0200 Subject: [PATCH 006/128] bump to v1.5.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 94133be89..7a3ba0e25 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.5.6", + "version": "1.5.7", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From da1a8cdd67045d8d644be8d3a47509a658eb7817 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 19 Oct 2023 10:13:05 +0200 Subject: [PATCH 007/128] web: Fix themes tab --- src/components/VencordSettings/ThemesTab.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index f19cdcb84..e65de2192 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -25,7 +25,7 @@ import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { showItemInFolder } from "@utils/native"; import { useAwaiter } from "@utils/react"; -import { findByCodeLazy, findByPropsLazy, findLazy } from "@webpack"; +import { findByPropsLazy, findLazy } from "@webpack"; import { Button, Card, FluxDispatcher, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common"; import { UserThemeHeader } from "main/themes"; import type { ComponentType, Ref, SyntheticEvent } from "react"; @@ -41,7 +41,7 @@ type FileInput = ComponentType<{ }>; const InviteActions = findByPropsLazy("resolveInvite"); -const FileInput: FileInput = findByCodeLazy("activateUploadDialogue="); +const FileInput: FileInput = findLazy(m => m.prototype?.activateUploadDialogue && m.prototype.setRef); const TextAreaProps = findLazy(m => typeof m.textarea === "string"); const cl = classNameFactory("vc-settings-theme-"); From d94418f42fa07a337810a0b66f913c2c81b8f1de Mon Sep 17 00:00:00 2001 From: ioj4 <69911332+ioj4@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:14:40 +0200 Subject: [PATCH 008/128] fix: windows host update patching (#1820) --- scripts/build/build.mjs | 2 +- src/main/patchWin32Updater.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index c8978a4b3..f606f1b08 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -43,7 +43,7 @@ const nodeCommonOpts = { format: "cjs", platform: "node", target: ["esnext"], - external: ["electron", ...commonOpts.external], + external: ["electron", "original-fs", ...commonOpts.external], define: defines, }; diff --git a/src/main/patchWin32Updater.ts b/src/main/patchWin32Updater.ts index 1be5812e7..ba7a9224e 100644 --- a/src/main/patchWin32Updater.ts +++ b/src/main/patchWin32Updater.ts @@ -17,7 +17,7 @@ */ import { app } from "electron"; -import { existsSync, mkdirSync, readdirSync, renameSync, statSync, writeFileSync } from "fs"; +import { existsSync, mkdirSync, readdirSync, renameSync, statSync, writeFileSync } from "original-fs"; import { basename, dirname, join } from "path"; function isNewer($new: string, old: string) { From c25c95eecd1dcda62db73169877d84e9f12b38d5 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:00:09 -0300 Subject: [PATCH 009/128] Fix IgnoreActivities making reporter angry --- src/plugins/ignoreActivities/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index e2888dd1e..18dd7993e 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -106,7 +106,7 @@ export default definePlugin({ } }, { - find: ".Messages.EMBEDDED_ACTIVITIES_HAVE_PLAYED_ONE_KNOWN", + find: ".Messages.EMBEDDED_ACTIVITIES_DEVELOPER_SHELF_SUBTITLE", replacement: [ { match: /(?<=\(\)\.activityTitleText.+?children:(\i)\.name.*?}\),)/, From b2a1410a96c8cfa21c86383415098eec6d5c765e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:03:54 -0300 Subject: [PATCH 010/128] Remove useless Experiments patch --- src/plugins/experiments/index.tsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/plugins/experiments/index.tsx b/src/plugins/experiments/index.tsx index cf5f4e6fd..149c436c2 100644 --- a/src/plugins/experiments/index.tsx +++ b/src/plugins/experiments/index.tsx @@ -77,15 +77,6 @@ export default definePlugin({ } ] }, - // Fix search history being disabled / broken with isStaff - { - find: 'get("disable_new_search")', - predicate: () => settings.store.enableIsStaff, - replacement: { - match: /(?<=showNewSearch"\);return)\s?!/, - replace: "!1&&!" - } - }, { find: 'H1,title:"Experiments"', replacement: { From 6c1b8b0d8a2c30ea28ddaea79d133b5c763369a4 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:04:22 -0300 Subject: [PATCH 011/128] Fix MessageDecorationsAPI --- src/plugins/_api/messageDecorations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_api/messageDecorations.ts b/src/plugins/_api/messageDecorations.ts index a3b251830..39f77e544 100644 --- a/src/plugins/_api/messageDecorations.ts +++ b/src/plugins/_api/messageDecorations.ts @@ -27,7 +27,7 @@ export default definePlugin({ { find: ".withMentionPrefix", replacement: { - match: /(.roleDot.{10,50}{children:.{1,2})}\)/, + match: /(currentUserIsPremium:.{10,50}{children:.{1,2})}\)/, replace: "$1.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))})" } } From 5a0b2ee3f50c1d14bb7bd6af20d8fdd5532cac71 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:04:32 -0300 Subject: [PATCH 012/128] Fix FakeNitro patch --- src/plugins/fakeNitro/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/fakeNitro/index.ts b/src/plugins/fakeNitro/index.ts index a11a43de0..a6ddb4723 100644 --- a/src/plugins/fakeNitro/index.ts +++ b/src/plugins/fakeNitro/index.ts @@ -295,7 +295,7 @@ export default definePlugin({ }, { predicate: () => settings.store.transformStickers, - match: /renderAttachments=function\(\i\){var (\i)=\i.attachments.+?;/, + match: /renderAttachments=function\(\i\){var \i=this,(\i)=\i.attachments.+?;/, replace: (m, attachments) => `${m}${attachments}=$self.filterAttachments(${attachments});` } ] From fe60a72b804fd8a609c36fc568bd81143dac2b19 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:13:49 -0300 Subject: [PATCH 013/128] Fix NoPendingCount patch --- src/plugins/noPendingCount/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 2ce375e00..21bd196a6 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -84,8 +84,8 @@ export default definePlugin({ find: "showProgressBadge:", predicate: () => settings.store.hidePremiumOffersCount, replacement: { - match: /\(function\(\){return \i\.\i\.getUnacknowledgedOffers\(\i\)\.length}\)/, - replace: "(function(){return 0})" + match: /=\i\.unviewedTrialCount\+\i\.unviewedDiscountCount/, + replace: "=0" } } ], From ae1dc4eab0b668318d3a1d274178c52f62a8e46d Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:51:07 -0300 Subject: [PATCH 014/128] Make reporter ignore useless Discord errors (#1829) --- scripts/generateReport.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 68e3c8081..180212126 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -61,6 +61,13 @@ const report = { otherErrors: [] as string[] }; +const IGNORED_DISCORD_ERRORS = [ + "KeybindStore: Looking for callback action", + "Unable to process domain list delta: Client revision number is null", + "Downloading the full bad domains file", + /\[GatewaySocket\].{0,110}Cannot access '/ +] as Array; + function toCodeBlock(s: string) { s = s.replace(/```/g, "`\u200B`\u200B`"); return "```" + s + " ```"; @@ -86,6 +93,8 @@ async function printReport() { console.log(` - Error: ${toCodeBlock(p.error)}`); }); + report.otherErrors = report.otherErrors.filter(e => !IGNORED_DISCORD_ERRORS.some(regex => e.match(regex))); + console.log("## Discord Errors"); report.otherErrors.forEach(e => { console.log(`- ${toCodeBlock(e)}`); From f659c46031c05f8255a2849cf99b43038650257a Mon Sep 17 00:00:00 2001 From: zImPatrick <23613354+zImPatrick@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:53:00 +0200 Subject: [PATCH 015/128] FakeNitro: Add app icon customization (#1822) Co-authored-by: V --- src/plugins/fakeNitro/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/plugins/fakeNitro/index.ts b/src/plugins/fakeNitro/index.ts index a6ddb4723..677286e72 100644 --- a/src/plugins/fakeNitro/index.ts +++ b/src/plugins/fakeNitro/index.ts @@ -329,6 +329,20 @@ export default definePlugin({ match: /(?<=\.Messages\.EMOJI_POPOUT_ADDED_PACK_DESCRIPTION.+?return ).{0,1200}\.Messages\.EMOJI_POPOUT_UNJOINED_DISCOVERABLE_GUILD_DESCRIPTION.+?(?=}\()/, replace: reactNode => `$self.addFakeNotice(${FakeNoticeType.Emoji},${reactNode},!!arguments[0]?.fakeNitroNode?.fake)` } + }, + { + find: "canUsePremiumAppIcons:function", + replacement: { + match: /canUsePremiumAppIcons:function\(\i\){/, + replace: "$&return true;" + } + }, + { + find: "location:\"AppIconHome\"", + replacement: { + match: /\i\.\i\.isPremium\(\i\.\i\.getCurrentUser\(\)\)/, + replace: "true" + } } ], From fada76ec81d8d18bc4d1a92c09078bee42305cb8 Mon Sep 17 00:00:00 2001 From: Macintosh II <95250141+mctaylors@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:41:56 +0300 Subject: [PATCH 016/128] PlatformIndicators: make size same as other memberlist icons (#1789) Co-authored-by: V --- src/plugins/platformIndicators/index.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index 6a7a8be74..7233cd13d 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -30,13 +30,13 @@ import { User } from "discord-types/general"; const SessionsStore = findStoreLazy("SessionsStore"); function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) { - return ({ color, tooltip }: { color: string; tooltip: string; }) => ( + return ({ color, tooltip, small }: { color: string; tooltip: string; small: boolean; }) => ( {(tooltipProps: any) => ( @@ -57,16 +57,16 @@ type Platform = keyof typeof Icons; const getStatusColor = findByCodeLazy(".TWITCH", ".STREAMING", ".INVISIBLE"); -const PlatformIcon = ({ platform, status }: { platform: Platform, status: string; }) => { +const PlatformIcon = ({ platform, status, small }: { platform: Platform, status: string; small: boolean; }) => { const tooltip = platform[0].toUpperCase() + platform.slice(1); const Icon = Icons[platform] ?? Icons.desktop; - return ; + return ; }; const getStatus = (id: string): Record => PresenceStore.getState()?.clientStatuses?.[id]; -const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false }: { user: User; wantMargin?: boolean; wantTopMargin?: boolean; }) => { +const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false, small = false }: { user: User; wantMargin?: boolean; wantTopMargin?: boolean; small?: boolean; }) => { if (!user || user.bot) return null; if (user.id === UserStore.getCurrentUser().id) { @@ -99,6 +99,7 @@ const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false }: { key={platform} platform={platform as Platform} status={status} + small={small} /> )); @@ -137,7 +138,7 @@ const indicatorLocations = { description: "In the member list", onEnable: () => addDecorator("platform-indicator", props => - + ), onDisable: () => removeDecorator("platform-indicator") From e4485165d0a7c5781b4078cf52a5e32213c6a854 Mon Sep 17 00:00:00 2001 From: Dea Date: Sat, 21 Oct 2023 16:42:37 +0000 Subject: [PATCH 017/128] onePingPerDM: add settings (#1802) Co-authored-by: V Co-authored-by: Dea --- src/plugins/onePingPerDM/index.ts | 40 +++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/plugins/onePingPerDM/index.ts b/src/plugins/onePingPerDM/index.ts index 47502ebe8..e69620ae7 100644 --- a/src/plugins/onePingPerDM/index.ts +++ b/src/plugins/onePingPerDM/index.ts @@ -4,20 +4,44 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; -import { ChannelStore, ReadStateStore } from "@webpack/common"; -import { Message } from "discord-types/general"; +import definePlugin, { OptionType } from "@utils/types"; +import { ChannelStore, ReadStateStore, UserStore } from "@webpack/common"; +import { MessageJSON } from "discord-types/general"; const enum ChannelType { DM = 1, GROUP_DM = 3 } +const settings = definePluginSettings({ + channelToAffect: { + type: OptionType.SELECT, + description: "Select the type of DM for the plugin to affect", + options: [ + { label: "Both", value: "both_dms", default: true }, + { label: "User DMs", value: "user_dm" }, + { label: "Group DMs", value: "group_dm" }, + ] + }, + allowMentions: { + type: OptionType.BOOLEAN, + description: "Receive audio pings for @mentions", + default: false, + }, + allowEveryone: { + type: OptionType.BOOLEAN, + description: "Receive audio pings for @everyone and @here in group DMs", + default: false, + }, +}); + export default definePlugin({ name: "OnePingPerDM", description: "If unread messages are sent by a user in DMs multiple times, you'll only receive one audio ping. Read the messages to reset the limit", authors: [Devs.ProffDea], + settings, patches: [{ find: ".getDesktopType()===", replacement: [{ @@ -29,11 +53,19 @@ export default definePlugin({ replace: "sound:!$self.isPrivateChannelRead(arguments[0]?.message)?undefined:$1" }] }], - isPrivateChannelRead(message: Message) { + isPrivateChannelRead(message: MessageJSON) { const channelType = ChannelStore.getChannel(message.channel_id)?.type; if (channelType !== ChannelType.DM && channelType !== ChannelType.GROUP_DM) { return false; } + if ( + (channelType === ChannelType.DM && settings.store.channelToAffect === "group_dm") || + (channelType === ChannelType.GROUP_DM && settings.store.channelToAffect === "user_dm") || + (settings.store.allowMentions && message.mentions.some(m => m.id === UserStore.getCurrentUser().id)) || + (settings.store.allowEveryone && message.mention_everyone) + ) { + return true; + } return ReadStateStore.getOldestUnreadMessageId(message.channel_id) === message.id; }, }); From 544edce9f9da6263a20a293e6b4d0a60e5657253 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 21 Oct 2023 19:26:29 +0200 Subject: [PATCH 018/128] bump to v1.5.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a3ba0e25..9ab6b2233 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.5.7", + "version": "1.5.8", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 4a2def03e764138c46607ad2981f9d539df19465 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:42:23 -0300 Subject: [PATCH 019/128] Fix MessageDecorationsAPI patch --- src/plugins/_api/messageDecorations.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/_api/messageDecorations.ts b/src/plugins/_api/messageDecorations.ts index 39f77e544..3c235d768 100644 --- a/src/plugins/_api/messageDecorations.ts +++ b/src/plugins/_api/messageDecorations.ts @@ -27,8 +27,8 @@ export default definePlugin({ { find: ".withMentionPrefix", replacement: { - match: /(currentUserIsPremium:.{10,50}{children:.{1,2})}\)/, - replace: "$1.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))})" + match: /currentUserIsPremium:.{0,70}{children:\i(?=}\))/, + replace: "$&.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))" } } ], From 1a1d9b07e8fc5976989437caa1407b41eb96d3e9 Mon Sep 17 00:00:00 2001 From: V Date: Wed, 25 Oct 2023 00:17:11 +0200 Subject: [PATCH 020/128] Fix canary crashing (#1833) --- src/plugins/_core/settings.tsx | 22 +++++----- src/plugins/messageLogger/index.tsx | 2 +- .../components/PronounsChatComponent.tsx | 13 +++--- src/plugins/pronoundb/index.ts | 4 +- src/utils/modal.tsx | 9 +--- src/webpack/common/stores.ts | 12 +++++- src/webpack/common/utils.ts | 12 +++++- src/webpack/patchWebpack.ts | 6 +-- src/webpack/webpack.ts | 43 ++++++++++++++++++- 9 files changed, 87 insertions(+), 36 deletions(-) diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index f7fcdd0aa..6f43b76a8 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -63,26 +63,26 @@ export default definePlugin({ replacement: { get match() { switch (Settings.plugins.Settings.settingsLocation) { - case "top": return /\{section:(\i)\.ID\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS\}/; - case "aboveNitro": return /\{section:(\i)\.ID\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS\}/; - case "belowNitro": return /\{section:(\i)\.ID\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS\}/; - case "belowActivity": return /(?<=\{section:(\i)\.ID\.DIVIDER},)\{section:"changelog"/; - case "bottom": return /\{section:(\i)\.ID\.CUSTOM,\s*element:.+?}/; + case "top": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS\}/; + case "aboveNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS\}/; + case "belowNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS\}/; + case "belowActivity": return /(?<=\{section:(\i\.\i)\.DIVIDER},)\{section:"changelog"/; + case "bottom": return /\{section:(\i\.\i)\.CUSTOM,\s*element:.+?}/; case "aboveActivity": default: - return /\{section:(\i)\.ID\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS\}/; + return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS\}/; } }, replace: "...$self.makeSettingsCategories($1),$&" } }], - customSections: [] as ((ID: Record) => any)[], + customSections: [] as ((SectionTypes: Record) => any)[], - makeSettingsCategories({ ID }: { ID: Record; }) { + makeSettingsCategories(SectionTypes: Record) { return [ { - section: ID.HEADER, + section: SectionTypes.HEADER, label: "Vencord", className: "vc-settings-header" }, @@ -128,9 +128,9 @@ export default definePlugin({ element: require("@components/VencordSettings/PatchHelperTab").default, className: "vc-patch-helper" }, - ...this.customSections.map(func => func(ID)), + ...this.customSections.map(func => func(SectionTypes)), { - section: ID.DIVIDER + section: SectionTypes.DIVIDER } ].filter(Boolean); }, diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 645892810..934df2fbe 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -360,7 +360,7 @@ export default definePlugin({ { // Render editHistory in the deepest div for message content match: /(\)\("div",\{id:.+?children:\[)/, - replace: "$1 (arguments[0].message.editHistory.length > 0 ? arguments[0].message.editHistory.map(edit => $self.renderEdit(edit)) : null), " + replace: "$1 (arguments[0].message.editHistory?.length > 0 ? arguments[0].message.editHistory.map(edit => $self.renderEdit(edit)) : null), " } ] }, diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 97d24943d..64fac18ba 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import ErrorBoundary from "@components/ErrorBoundary"; import { classes } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; import { UserStore } from "@webpack/common"; @@ -39,17 +40,17 @@ function shouldShow(message: Message): boolean { return true; } -export function PronounsChatComponentWrapper({ message }: { message: Message; }) { +export const PronounsChatComponentWrapper = ErrorBoundary.wrap(({ message }: { message: Message; }) => { return shouldShow(message) ? : null; -} +}, { noop: true }); -export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) { +export const CompactPronounsChatComponentWrapper = ErrorBoundary.wrap(({ message }: { message: Message; }) => { return shouldShow(message) ? : null; -} +}, { noop: true }); function PronounsChatComponent({ message }: { message: Message; }) { const [result] = useFormattedPronouns(message.author.id); @@ -63,7 +64,7 @@ function PronounsChatComponent({ message }: { message: Message; }) { : null; } -export function CompactPronounsChatComponent({ message }: { message: Message; }) { +export const CompactPronounsChatComponent = ErrorBoundary.wrap(({ message }: { message: Message; }) => { const [result] = useFormattedPronouns(message.author.id); return result @@ -73,4 +74,4 @@ export function CompactPronounsChatComponent({ message }: { message: Message; }) >• {result} ) : null; -} +}, { noop: true }); diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index c9dc2725e..bd5b2c5a9 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -41,7 +41,7 @@ export default definePlugin({ find: "showCommunicationDisabledStyles", replacement: { match: /("span",{id:\i,className:\i,children:\i}\))/, - replace: "$1, $self.CompactPronounsChatComponentWrapper(e)" + replace: "$1, $self.CompactPronounsChatComponentWrapper(arguments[0])" } }, // Patch the chat timestamp element (normal mode) @@ -49,7 +49,7 @@ export default definePlugin({ find: "showCommunicationDisabledStyles", replacement: { match: /(?<=return\s*\(0,\i\.jsxs?\)\(.+!\i&&)(\(0,\i.jsxs?\)\(.+?\{.+?\}\))/, - replace: "[$1, $self.PronounsChatComponentWrapper(e)]" + replace: "[$1, $self.PronounsChatComponentWrapper(arguments[0])]" } }, // Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns diff --git a/src/utils/modal.tsx b/src/utils/modal.tsx index 4ac6f9b1f..d7a054a5b 100644 --- a/src/utils/modal.tsx +++ b/src/utils/modal.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { filters, findByCode, mapMangledModuleLazy } from "@webpack"; +import { filters, findByCode, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; import type { ComponentType, PropsWithChildren, ReactNode, Ref } from "react"; import { LazyComponent } from "./react"; @@ -132,12 +132,7 @@ export const ModalContent = LazyComponent(() => Modals.ModalContent); export const ModalFooter = LazyComponent(() => Modals.ModalFooter); export const ModalCloseButton = LazyComponent(() => Modals.ModalCloseButton); -const ModalAPI = mapMangledModuleLazy("onCloseRequest:null!=", { - openModal: filters.byCode("onCloseRequest:null!="), - closeModal: filters.byCode("onCloseCallback&&"), - openModalLazy: m => m?.length === 1 && filters.byCode(".apply(this,arguments)")(m), - closeAllModals: filters.byCode(".value.key,") -}); +const ModalAPI = findByPropsLazy("openModalLazy"); /** * Wait for the render promise to resolve, then open a modal with it. diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index d42cb6b56..c4ebd4a95 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -16,10 +16,11 @@ * along with this program. If not, see . */ +import { proxyLazy } from "@utils/lazy"; import type * as Stores from "discord-types/stores"; // eslint-disable-next-line path-alias/no-relative -import { filters, findByCodeLazy, findByPropsLazy, mapMangledModuleLazy } from "../webpack"; +import { filters, findByCode, findByProps, findByPropsLazy, mapMangledModuleLazy } from "../webpack"; import { waitForStore } from "./internal"; import * as t from "./types/stores"; @@ -83,7 +84,14 @@ export const useStateFromStores: ( idk?: any, isEqual?: (old: T, newer: T) => boolean ) => T - = findByCodeLazy("useStateFromStores"); + // FIXME: hack to support old stable and new canary + = proxyLazy(() => { + try { + return findByProps("useStateFromStores").useStateFromStores; + } catch { + return findByCode('("useStateFromStores")'); + } + }); waitForStore("DraftStore", s => DraftStore = s); waitForStore("UserStore", s => UserStore = s); diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 2c814de57..bc97f5e74 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -16,10 +16,11 @@ * along with this program. If not, see . */ +import { proxyLazy } from "@utils/lazy"; import type { User } from "discord-types/general"; // eslint-disable-next-line path-alias/no-relative -import { _resolveReady, filters, findByCodeLazy, findByPropsLazy, findLazy, mapMangledModuleLazy, waitFor } from "../webpack"; +import { _resolveReady, filters, find, findByCodeLazy, findByPropsLazy, findLazy, mapMangledModuleLazy, waitFor } from "../webpack"; import type * as t from "./types/utils"; export let FluxDispatcher: t.FluxDispatcher; @@ -126,4 +127,11 @@ waitFor("parseTopic", m => Parser = m); export let SettingsRouter: any; waitFor(["open", "saveAccountChanges"], m => SettingsRouter = m); -export const PermissionsBits: t.PermissionsBits = findLazy(m => typeof m.ADMINISTRATOR === "bigint"); +// FIXME: hack to support old stable and new canary +export const PermissionsBits: t.PermissionsBits = proxyLazy(() => { + try { + return find(m => m.Permissions?.ADMINISTRATOR).Permissions; + } catch { + return find(m => typeof m.ADMINISTRATOR === "bigint"); + } +}); diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index f422372c1..9e7af6b73 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -36,9 +36,8 @@ if (window[WEBPACK_CHUNK]) { Object.defineProperty(window, WEBPACK_CHUNK, { get: () => webpackChunk, set: v => { - if (v?.push !== Array.prototype.push) { + if (v?.push !== Array.prototype.push && _initWebpack(v)) { logger.info(`Patching ${WEBPACK_CHUNK}.push`); - _initWebpack(v); patchPush(); // @ts-ignore delete window[WEBPACK_CHUNK]; @@ -85,10 +84,9 @@ function patchPush() { logger.error("Error in patched chunk", err); return void originalMod(module, exports, require); } - // There are (at the time of writing) 11 modules exporting the window // Make these non enumerable to improve webpack search performance - if (module.exports === window) { + if (exports === window) { Object.defineProperty(require.c, id, { value: require.c[id], enumerable: false, diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index b4a896086..1fdfa43e9 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -62,9 +62,50 @@ export type CallbackFn = (mod: any, id: number) => void; export function _initWebpack(instance: typeof window.webpackChunkdiscord_app) { if (cache !== void 0) throw "no."; - wreq = instance.push([[Symbol("Vencord")], {}, r => r]); + instance.push([[Symbol("Vencord")], {}, r => wreq = r]); + if (!wreq) return false; + cache = wreq.c; instance.pop(); + + for (const id in cache) { + const { exports } = cache[id]; + if (!exports) continue; + + const numberId = Number(id); + + for (const callback of listeners) { + try { + callback(exports, numberId); + } catch (err) { + logger.error("Error in webpack listener", err); + } + } + + for (const [filter, callback] of subscriptions) { + try { + if (filter(exports)) { + subscriptions.delete(filter); + callback(exports, numberId); + } else if (typeof exports === "object") { + if (exports.default && filter(exports.default)) { + subscriptions.delete(filter); + callback(exports.default, numberId); + } + + for (const nested in exports) if (nested.length <= 3) { + if (exports[nested] && filter(exports[nested])) { + subscriptions.delete(filter); + callback(exports[nested], numberId); + } + } + } + } catch (err) { + logger.error("Error while firing callback for webpack chunk", err); + } + } + } + return true; } if (IS_DEV && IS_DISCORD_DESKTOP) { From 97c0face2f246b9534c1a1c30bc402976924ad02 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 00:38:02 +0200 Subject: [PATCH 021/128] PinDMs: Fix canary crash --- src/plugins/pinDms/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 02fe332dc..a7406aa41 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -81,7 +81,7 @@ export default definePlugin({ // array with the count, or an empty array. Due to spreading, only in the former // case will an element be added to the outer array // Thanks for the fix, Strencher! - replace: "$&...$1.props.pinCount," + replace: "$&...($1.props.pinCount ?? [])," }, { // Patch renderSection (renders the header) to set the text to "Pinned DMs" instead of "Direct Messages" From 4e27722b543f8a7c86270276df68d7cb89adeec3 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 14:26:10 +0200 Subject: [PATCH 022/128] fix webpack patching --- src/plugins/_core/noTrack.ts | 2 +- src/webpack/patchWebpack.ts | 36 ++++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index 79ef5a6ef..4267a6280 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -24,7 +24,7 @@ export default definePlugin({ description: "Disable Discord's tracking ('science'), metrics and Sentry crash reporting", authors: [Devs.Cyn, Devs.Ven, Devs.Nuckyz, Devs.Arrow], required: true, - patches: [ + patches: true ? [] : [ { find: "TRACKING_URL:", replacement: { diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 9e7af6b73..a3bc7a6f6 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -31,17 +31,23 @@ const logger = new Logger("WebpackInterceptor", "#8caaee"); if (window[WEBPACK_CHUNK]) { logger.info(`Patching ${WEBPACK_CHUNK}.push (was already existant, likely from cache!)`); _initWebpack(window[WEBPACK_CHUNK]); - patchPush(); + patchPush(window[WEBPACK_CHUNK]); } else { Object.defineProperty(window, WEBPACK_CHUNK, { get: () => webpackChunk, set: v => { - if (v?.push !== Array.prototype.push && _initWebpack(v)) { - logger.info(`Patching ${WEBPACK_CHUNK}.push`); - patchPush(); - // @ts-ignore - delete window[WEBPACK_CHUNK]; - window[WEBPACK_CHUNK] = v; + if (v?.push) { + if (!v.push.$$vencordOriginal) { + logger.info(`Patching ${WEBPACK_CHUNK}.push`); + patchPush(v); + } + + if (_initWebpack(v)) { + logger.info("Successfully initialised Vencord webpack"); + // @ts-ignore + delete window[WEBPACK_CHUNK]; + window[WEBPACK_CHUNK] = v; + } } webpackChunk = v; }, @@ -49,7 +55,7 @@ if (window[WEBPACK_CHUNK]) { }); } -function patchPush() { +function patchPush(webpackGlobal: any) { function handlePush(chunk: any) { try { const modules = chunk[1]; @@ -213,13 +219,19 @@ function patchPush() { logger.error("Error in handlePush", err); } - return handlePush.original.call(window[WEBPACK_CHUNK], chunk); + return handlePush.$$vencordOriginal.call(webpackGlobal, chunk); } - handlePush.original = window[WEBPACK_CHUNK].push; - Object.defineProperty(window[WEBPACK_CHUNK], "push", { + handlePush.$$vencordOriginal = webpackGlobal.push; + Object.defineProperty(webpackGlobal, "push", { get: () => handlePush, - set: v => (handlePush.original = v), + set(v) { + Object.defineProperty(this, "push", { + value: v, + configurable: true + }); + patchPush(this); + }, configurable: true }); } From 4da79abb2149013ca6e3ed8b28d7073695bf1106 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 14:37:54 +0200 Subject: [PATCH 023/128] Fix components filter --- src/webpack/common/components.ts | 2 +- src/webpack/patchWebpack.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/webpack/common/components.ts b/src/webpack/common/components.ts index 55d3b84d4..e44b1c9f6 100644 --- a/src/webpack/common/components.ts +++ b/src/webpack/common/components.ts @@ -55,7 +55,7 @@ export const MaskedLink = waitForComponent("MaskedLink", m => m?.t export const Timestamp = waitForComponent("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format")); export const Flex = waitForComponent("Flex", ["Justify", "Align", "Wrap"]); -waitFor("FormItem", m => { +waitFor(["FormItem", "Button"], m => { ({ useToken, Card, Button, FormSwitch: Switch, Tooltip, TextInput, TextArea, Text, Select, SearchableSelect, Slider, ButtonLooks, TabBar, Popout, Dialog, Paginator, ScrollerThin, Clickable, Avatar } = m); Forms = m; }); diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index a3bc7a6f6..395c35fe5 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -90,6 +90,11 @@ function patchPush(webpackGlobal: any) { logger.error("Error in patched chunk", err); return void originalMod(module, exports, require); } + + exports = module.exports; + + if (!exports) return; + // There are (at the time of writing) 11 modules exporting the window // Make these non enumerable to improve webpack search performance if (exports === window) { @@ -226,11 +231,9 @@ function patchPush(webpackGlobal: any) { Object.defineProperty(webpackGlobal, "push", { get: () => handlePush, set(v) { - Object.defineProperty(this, "push", { - value: v, - configurable: true - }); - patchPush(this); + delete webpackGlobal.push; + webpackGlobal.push = v; + patchPush(webpackGlobal); }, configurable: true }); From 4beef9f73be01716a9e5dc880e28afd0c821a571 Mon Sep 17 00:00:00 2001 From: megumin Date: Wed, 25 Oct 2023 13:39:57 +0100 Subject: [PATCH 024/128] fix: ComponentDispatch and GifPaste plugin (#1843) Co-authored-by: V --- .eslintrc.json | 5 ++++- src/plugins/gifPaste/index.ts | 2 +- src/webpack/common/utils.ts | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8fa3386ab..2ee24e8b3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -51,7 +51,10 @@ "eqeqeq": ["error", "always", { "null": "ignore" }], "spaced-comment": ["error", "always", { "markers": ["!"] }], "yoda": "error", - "prefer-destructuring": ["error", { "object": true, "array": false }], + "prefer-destructuring": ["error", { + "VariableDeclarator": { "array": false, "object": true }, + "AssignmentExpression": { "array": false, "object": false } + }], "operator-assignment": ["error", "always"], "no-useless-computed-key": "error", "no-unneeded-ternary": ["error", { "defaultAssignment": false }], diff --git a/src/plugins/gifPaste/index.ts b/src/plugins/gifPaste/index.ts index f1dfb2ff9..8c1303ba4 100644 --- a/src/plugins/gifPaste/index.ts +++ b/src/plugins/gifPaste/index.ts @@ -33,7 +33,7 @@ export default definePlugin({ patches: [{ find: ".handleSelectGIF=", replacement: { - match: /\.handleSelectGIF=function.+?\{/, + match: /\.handleSelectGIF=\i=>\{/, replace: ".handleSelectGIF=function(gif){return $self.handleSelect(gif);" } }], diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index bc97f5e74..25fda58bb 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -24,7 +24,9 @@ import { _resolveReady, filters, find, findByCodeLazy, findByPropsLazy, findLazy import type * as t from "./types/utils"; export let FluxDispatcher: t.FluxDispatcher; -export const ComponentDispatch = findLazy(m => m.emitter?._events?.INSERT_TEXT); +export let ComponentDispatch; +waitFor(["ComponentDispatch", "ComponentDispatcher"], m => ComponentDispatch = m.ComponentDispatch); + export const RestAPI: t.RestAPI = findByPropsLazy("getAPIBaseURL", "get"); export const moment: typeof import("moment") = findByPropsLazy("parseTwoDigitYear"); From cb93c11e166964b9f1f03a28cd1d0b7b246f5407 Mon Sep 17 00:00:00 2001 From: Erik <81252038+Captain8771@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:40:17 +0200 Subject: [PATCH 025/128] Fix CustomRPC (#1846) --- src/plugins/customRPC/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index a58e54260..2ec7f53f7 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -32,7 +32,7 @@ const Colors = findByPropsLazy("profileColors"); const assetManager = mapMangledModuleLazy( "getAssetImage: size must === [number, number] for Twitch", { - getAsset: filters.byCode("apply("), + getAsset: filters.byCode("APPLICATION_ASSETS_FETCH_SUCCESS"), } ); From 922e3ce6fec18a78488ca8efabfef9b6047c0f1d Mon Sep 17 00:00:00 2001 From: Syncx <47534062+Syncxv@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:10:50 +0530 Subject: [PATCH 026/128] fix: FavoriteGifSearch (#1842) --- src/plugins/favGifSearch/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/favGifSearch/index.tsx b/src/plugins/favGifSearch/index.tsx index d2966e95c..0cb5166e1 100644 --- a/src/plugins/favGifSearch/index.tsx +++ b/src/plugins/favGifSearch/index.tsx @@ -91,13 +91,13 @@ export default definePlugin({ patches: [ { - find: "renderCategoryExtras", + find: "renderHeaderContent()", replacement: [ { - // https://regex101.com/r/4uHtTE/1 + // https://regex101.com/r/07gpzP/1 // ($1 renderHeaderContent=function { ... switch (x) ... case FAVORITES:return) ($2) ($3 case default:return r.jsx(($), {...props})) - match: /(renderHeaderContent=function.{1,150}FAVORITES:return)(.{1,150};)(case.{1,200}default:return\(0,\i\.jsx\)\((?\i\.\i))/, - replace: "$1 this.state.resultType === \"Favorites\" ? $self.renderSearchBar(this, $) : $2; $3" + match: /(renderHeaderContent\(\).{1,150}FAVORITES:return)(.{1,150});(case.{1,200}default:return\(0,\i\.jsx\)\((?\i\..{1,10}),)/, + replace: "$1 this.state.resultType === 'Favorites' ? $self.renderSearchBar(this, $) : $2;$3" }, { // to persist filtered favorites when component re-renders. @@ -182,7 +182,7 @@ function SearchBar({ instance, SearchBarComponent }: { instance: Instance; Searc ref={ref} autoFocus={true} className={containerClasses.searchBar} - size={SearchBarComponent.Sizes.MEDIUM} + size={SearchBarComponent.Sizes.SMALL} onChange={onChange} onClear={() => { setQuery(""); From 09b646b86031312692a988c489bc6bad810906e3 Mon Sep 17 00:00:00 2001 From: Hugo C Date: Wed, 25 Oct 2023 14:41:09 +0200 Subject: [PATCH 027/128] fix: PictureInPicture (#1839) Co-authored-by: V --- src/plugins/pictureInPicture/index.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/pictureInPicture/index.tsx b/src/plugins/pictureInPicture/index.tsx index bb6aee18f..f5f0a5128 100644 --- a/src/plugins/pictureInPicture/index.tsx +++ b/src/plugins/pictureInPicture/index.tsx @@ -4,8 +4,6 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import "./styles.css"; - import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; @@ -26,13 +24,12 @@ export default definePlugin({ description: "Adds picture in picture to videos (next to the Download button)", authors: [Devs.Lumap], settings, - patches: [ { - find: ".onRemoveAttachment,", + find: ".nonMediaAttachment]", replacement: { - match: /\.nonMediaAttachment,!(\i).{0,7}children:\[(\i),/, - replace: "$&$1&&$2&&$self.renderPiPButton()," + match: /\.nonMediaAttachment\].{0,10}children:\[\S{3}/, + replace: "$&&&$self.renderPiPButton()," }, }, ], @@ -43,7 +40,6 @@ export default definePlugin({ {tooltipProps => (
From 940193c30bd0e426799e1507f74d47560d38e90a Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 19:47:08 +0700 Subject: [PATCH 028/128] noMosaic: fix (#1849) --- src/plugins/noMosaic/index.ts | 26 ++++++++++++++------------ src/plugins/noMosaic/styles.css | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/plugins/noMosaic/index.ts b/src/plugins/noMosaic/index.ts index 60576ba93..49343503d 100644 --- a/src/plugins/noMosaic/index.ts +++ b/src/plugins/noMosaic/index.ts @@ -15,23 +15,25 @@ export default definePlugin({ authors: [Devs.AutumnVN], description: "Removes Discord new image mosaic", tags: ["image", "mosaic", "media"], - patches: [{ - find: "Media Mosaic", - replacement: [ - { + patches: [ + { + find: ".oneByTwoLayoutThreeGrid", + replacement: [{ match: /mediaLayoutType:\i\.\i\.MOSAIC/, - replace: 'mediaLayoutType:"RESPONSIVE"', - }, - { - match: /\i===\i\.\i\.MOSAIC/, - replace: "true", + replace: 'mediaLayoutType:"RESPONSIVE"' }, { match: /null!==\(\i=\i\.get\(\i\)\)&&void 0!==\i\?\i:"INVALID"/, replace: '"INVALID"', - }, - ], - }], + },] + }, + { + find: "Messages.REMOVE_ATTACHMENT_TOOLTIP_TEXT", + replacement: { + match: /\i===\i\.\i\.MOSAIC/, + replace: "true" + } + }], start() { enableStyle(style); }, diff --git a/src/plugins/noMosaic/styles.css b/src/plugins/noMosaic/styles.css index 546168584..05ea24899 100644 --- a/src/plugins/noMosaic/styles.css +++ b/src/plugins/noMosaic/styles.css @@ -1,3 +1,3 @@ -[class^="nonMediaAttachmentsContainer-"] [class*="messageAttachment-"] { +[class^="nonMediaAttachmentsContainer_"] [class*="messageAttachment_"] { position: relative; } From baa7d8c078aab9a2e71a03784f5069e129be4716 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 19:48:05 +0700 Subject: [PATCH 029/128] noDevToolsWarning: fix (#1851) --- src/plugins/noDevtoolsWarning/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/noDevtoolsWarning/index.ts b/src/plugins/noDevtoolsWarning/index.ts index 188b8fa3f..e897e5793 100644 --- a/src/plugins/noDevtoolsWarning/index.ts +++ b/src/plugins/noDevtoolsWarning/index.ts @@ -26,8 +26,8 @@ export default definePlugin({ patches: [{ find: "setDevtoolsCallbacks", replacement: { - match: /if\(.{0,10}\|\|"0.0.0"!==.{0,2}\.remoteApp\.getVersion\(\)\)/, - replace: "if(false)" + match: /if\(null!=\i&&"0.0.0"===\i\.remoteApp\.getVersion\(\)\)/, + replace: "if(true)" } }] }); From 2a56081bc24c069df55857ed08c70c84449f1a40 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 19:48:42 +0700 Subject: [PATCH 030/128] callTimer: fix (#1850) --- src/plugins/callTimer/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/callTimer/index.tsx b/src/plugins/callTimer/index.tsx index 2e0aa9650..c018cc715 100644 --- a/src/plugins/callTimer/index.tsx +++ b/src/plugins/callTimer/index.tsx @@ -73,9 +73,9 @@ export default definePlugin({ }, patches: [{ - find: ".renderConnectionStatus=", + find: "renderConnectionStatus(){", replacement: { - match: /(?<=renderConnectionStatus=.+\.channel,children:)\w/, + match: /(?<=renderConnectionStatus\(\)\{.+\.channel,children:)\i/, replace: "[$&, $self.renderTimer(this.props.channel.id)]" } }], From 69b54535c33bc08495b068876ad61b1024b20610 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 14:56:20 +0200 Subject: [PATCH 031/128] Fix NoTrack --- src/plugins/_core/noTrack.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index 4267a6280..ca1126593 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -24,9 +24,9 @@ export default definePlugin({ description: "Disable Discord's tracking ('science'), metrics and Sentry crash reporting", authors: [Devs.Cyn, Devs.Ven, Devs.Nuckyz, Devs.Arrow], required: true, - patches: true ? [] : [ + patches: [ { - find: "TRACKING_URL:", + find: "AnalyticsActionHandlers.handle", replacement: { match: /^.+$/, replace: "()=>{}", @@ -43,8 +43,8 @@ export default definePlugin({ find: ".METRICS,", replacement: [ { - match: /this\._intervalId.+?12e4\)/, - replace: "" + match: /this\._intervalId=/, + replace: "this._intervalId=undefined&&" }, { match: /(?<=increment=function\(\i\){)/, From 7ee9a8bb990c6d28db1ecbac856fac6a82ac0cf4 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 14:58:59 +0200 Subject: [PATCH 032/128] SpotifyControls: Fix --- src/webpack/common/menu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webpack/common/menu.ts b/src/webpack/common/menu.ts index e2ad37202..c0d9c5f9d 100644 --- a/src/webpack/common/menu.ts +++ b/src/webpack/common/menu.ts @@ -22,7 +22,7 @@ import type * as t from "./types/menu"; export let Menu = {} as t.Menu; -waitFor("MenuItem", m => Menu = m); +waitFor(["MenuItem", "MenuSliderControl"], m => Menu = m); export const ContextMenu: t.ContextMenuApi = mapMangledModuleLazy('type:"CONTEXT_MENU_OPEN"', { open: filters.byCode("stopPropagation"), From 322ecc5e88b3dd027e62f2e83b550529741f4340 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 19:59:35 +0700 Subject: [PATCH 033/128] usrbg: fix (#1853) --- src/plugins/usrbg/index.css | 2 +- src/plugins/usrbg/index.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/usrbg/index.css b/src/plugins/usrbg/index.css index 93e37ef48..69c5b1857 100644 --- a/src/plugins/usrbg/index.css +++ b/src/plugins/usrbg/index.css @@ -7,6 +7,6 @@ top: 76px; } -[style*="background-image"] [class*="background-"] { +[style*="background-image"] [class*="background_"] { background-color: transparent !important; } diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index 3e8c12257..ce6bd709b 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -59,8 +59,8 @@ export default definePlugin({ replace: "$self.premiumHook($1)||$&" }, { - match: /(\i)\.bannerSrc,/, - replace: "$self.useBannerHook($1)," + match: /(?<=function \i\((\i)\)\{)(?=var.{30,50},bannerSrc:)/, + replace: "$1.bannerSrc=$self.useBannerHook($1);" }, { match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/, @@ -73,8 +73,8 @@ export default definePlugin({ predicate: () => settings.store.voiceBackground, replacement: [ { - match: /(\i)\.style,/, - replace: "$self.voiceBackgroundHook($1)," + match: /(?<=function\((\i),\i\)\{)(?=let.{20,40},style:)/, + replace: "$1.style=$self.voiceBackgroundHook($1);" } ] } @@ -90,7 +90,7 @@ export default definePlugin({ }, voiceBackgroundHook({ className, participantUserId }: any) { - if (className.includes("tile-")) { + if (className.includes("tile_")) { if (data[participantUserId]) { return { backgroundImage: `url(${data[participantUserId]})`, From 44c96757956428c7b74f37e52bb7e2a8eb7cf7cf Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 15:07:45 +0200 Subject: [PATCH 034/128] ContextMenuApi: fix --- src/plugins/_api/contextMenu.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/_api/contextMenu.ts b/src/plugins/_api/contextMenu.ts index d04e0e662..55fdf3eae 100644 --- a/src/plugins/_api/contextMenu.ts +++ b/src/plugins/_api/contextMenu.ts @@ -29,8 +29,8 @@ export default definePlugin({ { find: "♫ (つ。◕‿‿◕。)つ ♪", replacement: { - match: /(?<=function \i\((\i)\){)(?=var \i,\i=\i\.navId)/, - replace: (_, props) => `Vencord.Api.ContextMenu._patchContextMenu(${props});` + match: /let{navId:/, + replace: "Vencord.Api.ContextMenu._patchContextMenu(arguments[0]);$&" } }, { From 554bb18e9b6a554c9b7b5fd6d5e5613a3e529d3c Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 15:24:06 +0200 Subject: [PATCH 035/128] BadgeAPI: fix --- src/plugins/_api/badges.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/_api/badges.tsx b/src/plugins/_api/badges.tsx index d10d00210..11e843db4 100644 --- a/src/plugins/_api/badges.tsx +++ b/src/plugins/_api/badges.tsx @@ -85,17 +85,19 @@ export default definePlugin({ }, { // alt: "", aria-hidden: false, src: originalSrc - match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/g, + match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/, // ...badge.props, ..., src: badge.image ?? ... replace: "...$1.props,$& $1.image??" }, + // replace their component with ours if applicable { - match: /children:function(?<=(\i)\.(?:tooltip|description),spacing:\d.+?)/g, - replace: "children:$1.component ? () => $self.renderBadgeComponent($1) : function" + match: /(?<=text:(\i)\.description,spacing:12,)children:/, + replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :" }, + // conditionally override their onClick with badge.onClick if it exists { - match: /onClick:function(?=.{0,200}href:(\i)\.link)/, - replace: "onClick:$1.onClick??function" + match: /href:(\i)\.link/, + replace: "...($1.onClick && { onClick: $1.onClick }),$&" } ] } From fb22c57da13c5033d4d1764aabe355c0f509a4b4 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 15:28:50 +0200 Subject: [PATCH 036/128] MessageAccessoriesAPI: Fix --- src/plugins/_api/messageAccessories.ts | 5 ++--- src/webpack/webpack.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/_api/messageAccessories.ts b/src/plugins/_api/messageAccessories.ts index 5bb13cfe1..a98fdb32b 100644 --- a/src/plugins/_api/messageAccessories.ts +++ b/src/plugins/_api/messageAccessories.ts @@ -27,9 +27,8 @@ export default definePlugin({ { find: ".Messages.REMOVE_ATTACHMENT_BODY", replacement: { - match: /(.container\)?,children:)(\[[^\]]+\])(}\)\};return)/, - replace: (_, pre, accessories, post) => - `${pre}Vencord.Api.MessageAccessories._modifyAccessories(${accessories},this.props)${post}`, + match: /(?<=.container\)?,children:)(\[.+?\])/, + replace: "Vencord.Api.MessageAccessories._modifyAccessories($1,this.props)", }, }, ], diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 1fdfa43e9..812e36079 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -458,7 +458,7 @@ export function extract(id: number) { // WARNING: This module was extracted to be more easily readable. // This module is NOT ACTUALLY USED! This means putting breakpoints will have NO EFFECT!! -${mod.toString()} +0,${mod.toString()} //# sourceURL=ExtractedWebpackModule${id} `; const extracted = (0, eval)(code); From 8c998b9330af7e7db089709ba05170e2a3c45cfc Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 20:34:00 +0700 Subject: [PATCH 037/128] experiments: fix (#1855) --- src/plugins/experiments/index.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/experiments/index.tsx b/src/plugins/experiments/index.tsx index 149c436c2..89fcf33e7 100644 --- a/src/plugins/experiments/index.tsx +++ b/src/plugins/experiments/index.tsx @@ -52,7 +52,7 @@ export default definePlugin({ { find: "Object.defineProperties(this,{isDeveloper", replacement: { - match: /(?<={isDeveloper:\{[^}]+?,get:function\(\)\{return )\w/, + match: /(?<={isDeveloper:\{[^}]+?,get:\(\)=>)\i/, replace: "true" } }, @@ -64,19 +64,28 @@ export default definePlugin({ } }, { - find: ".isStaff=function(){", + find: ".isStaff=()", predicate: () => settings.store.enableIsStaff, replacement: [ { - match: /return\s*?(\i)\.hasFlag\((\i\.\i)\.STAFF\)}/, - replace: (_, user, flags) => `return Vencord.Webpack.Common.UserStore.getCurrentUser()?.id===${user}.id||${user}.hasFlag(${flags}.STAFF)}` + match: /=>*?(\i)\.hasFlag\((\i\.\i)\.STAFF\)}/, + replace: (_, user, flags) => `=>Vencord.Webpack.Common.UserStore.getCurrentUser()?.id===${user}.id||${user}.hasFlag(${flags}.STAFF)}` }, { - match: /hasFreePremium=function\(\){return this.isStaff\(\)\s*?\|\|/, - replace: "hasFreePremium=function(){return ", + match: /hasFreePremium\(\){return this.isStaff\(\)\s*?\|\|/, + replace: "hasFreePremium(){return ", } ] }, + // Fix search history being disabled / broken with isStaff + { + find: '("showNewSearch")', + predicate: () => settings.store.enableIsStaff, + replacement: { + match: /(?<=showNewSearch"\);return)\s?/, + replace: "!1&&" + } + }, { find: 'H1,title:"Experiments"', replacement: { From cb2532d22cb39232f362453e2fc1e935640e047f Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 20:34:17 +0700 Subject: [PATCH 038/128] disableDMCallIdle: fix (#1856) --- src/plugins/disableDMCallIdle/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/disableDMCallIdle/index.ts b/src/plugins/disableDMCallIdle/index.ts index 26ea3cdac..bce119d01 100644 --- a/src/plugins/disableDMCallIdle/index.ts +++ b/src/plugins/disableDMCallIdle/index.ts @@ -27,7 +27,7 @@ export default definePlugin({ { find: ".Messages.BOT_CALL_IDLE_DISCONNECT", replacement: { - match: /(?<=function \i\(\){)(?=.{1,100}\.Messages\.BOT_CALL_IDLE_DISCONNECT)/, + match: /(?<=function \i\(\){)(?=.{1,120}\.Messages\.BOT_CALL_IDLE_DISCONNECT)/, replace: "return;" } } From 4d8e4e62ca2783bea7963ce3267ebd1ab0d94bfb Mon Sep 17 00:00:00 2001 From: megumin Date: Wed, 25 Oct 2023 14:41:57 +0100 Subject: [PATCH 039/128] fix: notrack failing patches (#1857) --- src/plugins/_core/noTrack.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index ca1126593..424e62c04 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -47,16 +47,17 @@ export default definePlugin({ replace: "this._intervalId=undefined&&" }, { - match: /(?<=increment=function\(\i\){)/, - replace: "return;" + match: /(increment\(\i\){)/, + replace: "$1return;" } ] }, { find: ".installedLogHooks)", replacement: { - match: /if\(\i\.getDebugLogging\(\)&&!\i\.installedLogHooks\)/, - replace: "if(false)" + // if getDebugLogging() returns false, the hooks don't get installed. + match: "getDebugLogging(){", + replace: "getDebugLogging(){return false;" } }, ] From cf5e93ee52ad8f36014f07d6f3303cef88b2b875 Mon Sep 17 00:00:00 2001 From: Jack <30497388+FieryFlames@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:45:19 -0400 Subject: [PATCH 040/128] fix: fakeProfileThemes (#1837) --- src/plugins/fakeProfileThemes/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx index 70003e5ab..c61437269 100644 --- a/src/plugins/fakeProfileThemes/index.tsx +++ b/src/plugins/fakeProfileThemes/index.tsx @@ -87,15 +87,15 @@ export default definePlugin({ authors: [Devs.Alyxia, Devs.Remty], patches: [ { - find: "getUserProfile=", + find: "UserProfileStore", replacement: { - match: /(?<=getUserProfile=function\(\i\){return )(\i\[\i\])/, + match: /(?<=getUserProfile\(\i\){return )(\i\[\i\])/, replace: "$self.colorDecodeHook($1)" } }, { find: ".USER_SETTINGS_PROFILE_THEME_ACCENT", replacement: { - match: /RESET_PROFILE_THEME}\)(?<=},color:(\i).+?},color:(\i).+?)/, + match: /RESET_PROFILE_THEME}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/, replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})" } } From 65d39dcf21ecbcb1d45fefd38eee55965668de4b Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 25 Oct 2023 14:56:43 +0100 Subject: [PATCH 041/128] ShowConnections, NoProfileThemes: Fix (#1854) --- src/plugins/noProfileThemes/index.ts | 10 +++++----- src/plugins/showConnections/index.tsx | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/plugins/noProfileThemes/index.ts b/src/plugins/noProfileThemes/index.ts index 97d195e36..c31f42838 100644 --- a/src/plugins/noProfileThemes/index.ts +++ b/src/plugins/noProfileThemes/index.ts @@ -34,19 +34,19 @@ export default definePlugin({ } }, { - find: "().avatarPositionPremiumNoBanner,default:", + find: ".avatarPositionPremiumNoBanner,default:", replacement: { // premiumUserWithoutBanner: foo().avatarPositionPremiumNoBanner, default: foo().avatarPositionNormal - match: /\.avatarPositionPremiumNoBanner(?=,default:\i\(\)\.(\i))/, + match: /\.avatarPositionPremiumNoBanner(?=,default:\i\.(\i))/, // premiumUserWithoutBanner: foo().avatarPositionNormal... replace: ".$1" } }, { - find: ".hasThemeColors=function(){", + find: "hasThemeColors(){", replacement: { - match: /(?<=key:"canUsePremiumProfileCustomization",get:function\(\){return)/, - replace: " false;" + match: /get canUsePremiumProfileCustomization\(\){return /, + replace: "$&false &&" } } ] diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index 1f6ef34ef..948bdb83b 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -32,7 +32,7 @@ import { User } from "discord-types/general"; import { VerifiedIcon } from "./VerifiedIcon"; -const Section = LazyComponent(() => findByCode("().lastSection")); +const Section = LazyComponent(() => findByCode(".lastSection]:")); const ThemeStore = findStoreLazy("ThemeStore"); const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"'); @@ -74,12 +74,12 @@ interface ConnectionPlatform { icon: { lightSVG: string, darkSVG: string; }; } -const profilePopoutComponent = ErrorBoundary.wrap(e => - +const profilePopoutComponent = ErrorBoundary.wrap(({ user, displayProfile }: { user: User, displayProfile; }) => + ); -const profilePanelComponent = ErrorBoundary.wrap(e => - +const profilePanelComponent = ErrorBoundary.wrap(({ id }: { id: string; }) => + ); function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) { @@ -175,18 +175,18 @@ export default definePlugin({ authors: [Devs.TheKodeToad], patches: [ { - find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", + find: "{isUsingGuildBio:null!==(", replacement: { - match: /,theme:\i\}\)(?=,.{0,100}setNote:)/, - replace: "$&,$self.profilePopoutComponent(arguments[0])" + match: /,theme:\i\}\)(?=,.{0,150}setNote:)/, + replace: "$&,$self.profilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile })" } }, { find: "\"Profile Panel: user cannot be undefined\"", replacement: { // createElement(Divider, {}), createElement(NoteComponent) - match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:/, - replace: "$self.profilePanelComponent(arguments[0]),$&" + match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/, + replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&" } } ], From bb771153e3e620e52202935a5ec603f59b68ecfe Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 16:12:01 +0200 Subject: [PATCH 042/128] MessageEvents: Fix --- src/plugins/_api/messageEvents.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index fa467522c..bc5f5abf2 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -27,10 +27,8 @@ export default definePlugin({ { find: '"MessageActionCreators"', replacement: { - // editMessage: function (...) { - match: /\beditMessage:(function\(.+?\))\{/, - // editMessage: async function (...) { await handlePreEdit(...); ... - replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);" + match: /async editMessage\(.+?\)\{/, + replace: "$&await Vencord.Api.MessageEvents._handlePreEdit(...arguments);" } }, { @@ -38,7 +36,7 @@ export default definePlugin({ replacement: { // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(props\.chatInputType.+?\.then\(\()(function.+?var (\i)=\i\.\i\.parse\((\i),.+?var (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, + match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + `${rest1}async ${rest2}` + @@ -49,10 +47,10 @@ export default definePlugin({ { find: '("interactionUsernameProfile', replacement: { - match: /var \i=(\i)\.id,\i=(\i)\.id;return \i\.useCallback\(\(?function\((\i)\){/, + match: /let\{id:\i}=(\i),{id:\i}=(\i);return \i\.useCallback\((\i)=>\{/, replace: (m, message, channel, event) => // the message param is shadowed by the event param, so need to alias them - `var _msg=${message},_chan=${channel};${m}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});` + `const vcMsg=${message},vcChan=${channel};${m}Vencord.Api.MessageEvents._handleClick(vcMsg, vcChan, ${event});` } } ] From 7e0fc1d0ea227743c88ce36df6f16a9658d44a95 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 16:15:52 +0200 Subject: [PATCH 043/128] ServerListAPI: fix --- src/plugins/_api/serverList.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/_api/serverList.ts b/src/plugins/_api/serverList.ts index ec377fce1..f45bbf104 100644 --- a/src/plugins/_api/serverList.ts +++ b/src/plugins/_api/serverList.ts @@ -27,15 +27,15 @@ export default definePlugin({ { find: "Messages.DISCODO_DISABLED", replacement: { - match: /(Messages\.DISCODO_DISABLED.+?return)(\(.{0,75}?tutorialContainer.+?}\))(?=}function)/, - replace: "$1[$2].concat(Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.Above))" + match: /(?<=Messages\.DISCODO_DISABLED.+?return)(\(.{0,75}?tutorialContainer.+?}\))(?=}function)/, + replace: "[$1].concat(Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.Above))" } }, { find: "Messages.SERVERS,children", replacement: { - match: /(Messages\.SERVERS,children:)(.+?default:return null\}\}\)\))/, - replace: "$1Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($2)" + match: /(?<=Messages\.SERVERS,children:).+?default:return null\}\}\)/, + replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)" } } ] From 98955409433ae8c38243dee36500adbb427ccf74 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 16:29:37 +0200 Subject: [PATCH 044/128] MemberListDecoratorAPI: Fix --- src/plugins/_api/memberListDecorators.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/_api/memberListDecorators.ts b/src/plugins/_api/memberListDecorators.ts index a6d4125d3..bf7377e85 100644 --- a/src/plugins/_api/memberListDecorators.ts +++ b/src/plugins/_api/memberListDecorators.ts @@ -25,18 +25,23 @@ export default definePlugin({ authors: [Devs.TheSun, Devs.Ven], patches: [ { - find: "lostPermissionTooltipText,", - replacement: { - match: /decorators:.{0,100}?children:\[(?<=(\i)\.lostPermissionTooltipText.+?)/, - replace: "$&...Vencord.Api.MemberListDecorators.__getDecorators($1)," - } + find: ".lostPermission)", + replacement: [ + { + match: /let\{[^}]*lostPermissionTooltipText:\i[^}]*\}=(\i),/, + replace: "$&vencordProps=$1," + }, { + match: /decorators:.{0,100}?children:\[/, + replace: "$&...(typeof vencordProps=='undefined'?[]:Vencord.Api.MemberListDecorators.__getDecorators(vencordProps))," + } + ] }, { find: "PrivateChannel.renderAvatar", replacement: [ // props are shadowed by nested props so we have to do this { - match: /\i=(\i)\.applicationStream,/, + match: /let\{[^}]*applicationStream:\i[^}]*\}=(\i),/, replace: "$&vencordProps=$1," }, { From 892a79b2a7c21d04aafdf8de54a117fb7522c2c0 Mon Sep 17 00:00:00 2001 From: redstonekasi Date: Wed, 25 Oct 2023 16:16:16 +0200 Subject: [PATCH 045/128] fix: CommandsAPI --- src/api/Commands/commandHelpers.ts | 6 +++--- src/plugins/_api/commands.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/Commands/commandHelpers.ts b/src/api/Commands/commandHelpers.ts index dd1196f9f..2fd189032 100644 --- a/src/api/Commands/commandHelpers.ts +++ b/src/api/Commands/commandHelpers.ts @@ -17,14 +17,14 @@ */ import { mergeDefaults } from "@utils/misc"; -import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { findByPropsLazy } from "@webpack"; import { SnowflakeUtils } from "@webpack/common"; import { Message } from "discord-types/general"; import type { PartialDeep } from "type-fest"; import { Argument } from "./types"; -const createBotMessage = findByCodeLazy('username:"Clyde"'); +const MessageCreator = findByPropsLazy("createBotMessage"); const MessageSender = findByPropsLazy("receiveMessage"); export function generateId() { @@ -38,7 +38,7 @@ export function generateId() { * @returns {Message} */ export function sendBotMessage(channelId: string, message: PartialDeep): Message { - const botMessage = createBotMessage({ channelId, content: "", embeds: [] }); + const botMessage = MessageCreator.createBotMessage({ channelId, content: "", embeds: [] }); MessageSender.receiveMessage(channelId, mergeDefaults(message, botMessage)); diff --git a/src/plugins/_api/commands.ts b/src/plugins/_api/commands.ts index b7d6ef9fe..3a7619365 100644 --- a/src/plugins/_api/commands.ts +++ b/src/plugins/_api/commands.ts @@ -44,8 +44,8 @@ export default definePlugin({ find: "Unexpected value for option", replacement: { // return [2, cmd.execute(args, ctx)] - match: /,(.{1,2})\.execute\((.{1,2}),(.{1,2})\)]/, - replace: (_, cmd, args, ctx) => `,Vencord.Api.Commands._handleCommand(${cmd}, ${args}, ${ctx})]` + match: /,(\i)\.execute\((\i),(\i)\)/, + replace: (_, cmd, args, ctx) => `,Vencord.Api.Commands._handleCommand(${cmd}, ${args}, ${ctx})` } }, // Show plugin name instead of "Built-In" From b69ac1cdad0de10dd20ae1954581f05bbef36a2e Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 16:50:09 +0200 Subject: [PATCH 046/128] Fix PlatformIndicators --- src/plugins/platformIndicators/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index 7233cd13d..5ccc3b783 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -23,7 +23,7 @@ import { Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; +import { findByPropsLazy, findStoreLazy } from "@webpack"; import { PresenceStore, Tooltip, UserStore } from "@webpack/common"; import { User } from "discord-types/general"; @@ -55,13 +55,13 @@ const Icons = { }; type Platform = keyof typeof Icons; -const getStatusColor = findByCodeLazy(".TWITCH", ".STREAMING", ".INVISIBLE"); +const StatusUtils = findByPropsLazy("getStatusColor", "StatusTypes"); const PlatformIcon = ({ platform, status, small }: { platform: Platform, status: string; small: boolean; }) => { const tooltip = platform[0].toUpperCase() + platform.slice(1); const Icon = Icons[platform] ?? Icons.desktop; - return ; + return ; }; const getStatus = (id: string): Record => PresenceStore.getState()?.clientStatuses?.[id]; From 788d22f9e90276e08ccfce83d113ce793f2655c8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 16:52:59 +0200 Subject: [PATCH 047/128] MessageDecorationsAPI: fix --- src/plugins/_api/messageDecorations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_api/messageDecorations.ts b/src/plugins/_api/messageDecorations.ts index 3c235d768..3f0fd11db 100644 --- a/src/plugins/_api/messageDecorations.ts +++ b/src/plugins/_api/messageDecorations.ts @@ -25,7 +25,7 @@ export default definePlugin({ authors: [Devs.TheSun], patches: [ { - find: ".withMentionPrefix", + find: "UsernameDecorationTypes:", replacement: { match: /currentUserIsPremium:.{0,70}{children:\i(?=}\))/, replace: "$&.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))" From 2478ffb695ee4e8225eb3dee7bc8dd57ee1ad4db Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Oct 2023 21:57:50 +0700 Subject: [PATCH 048/128] fix userutils (#1861) --- src/components/PluginSettings/PluginModal.tsx | 2 +- src/plugins/relationshipNotifier/functions.ts | 2 +- src/plugins/relationshipNotifier/utils.ts | 4 ++-- src/plugins/serverProfile/GuildProfileModal.tsx | 2 +- src/utils/discord.tsx | 2 +- src/webpack/common/utils.ts | 6 ++---- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index d8b949066..03789ac6c 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -94,7 +94,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti (async () => { for (const user of plugin.authors.slice(0, 6)) { const author = user.id - ? await UserUtils.fetchUser(`${user.id}`) + ? await UserUtils.getUser(`${user.id}`) .catch(() => makeDummyUser({ username: user.name })) : makeDummyUser({ username: user.name }); diff --git a/src/plugins/relationshipNotifier/functions.ts b/src/plugins/relationshipNotifier/functions.ts index e712382b5..980b11300 100644 --- a/src/plugins/relationshipNotifier/functions.ts +++ b/src/plugins/relationshipNotifier/functions.ts @@ -37,7 +37,7 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat return; } - const user = await UserUtils.fetchUser(id) + const user = await UserUtils.getUser(id) .catch(() => null); if (!user) return; diff --git a/src/plugins/relationshipNotifier/utils.ts b/src/plugins/relationshipNotifier/utils.ts index 5de9d75a7..16f1892af 100644 --- a/src/plugins/relationshipNotifier/utils.ts +++ b/src/plugins/relationshipNotifier/utils.ts @@ -68,7 +68,7 @@ export async function syncAndRunChecks() { for (const id of oldFriends.friends) { if (friends.friends.includes(id)) continue; - const user = await UserUtils.fetchUser(id).catch(() => void 0); + const user = await UserUtils.getUser(id).catch(() => void 0); if (user) notify( `You are no longer friends with ${getUniqueUsername(user)}.`, @@ -85,7 +85,7 @@ export async function syncAndRunChecks() { [RelationshipType.FRIEND, RelationshipType.BLOCKED, RelationshipType.OUTGOING_REQUEST].includes(RelationshipStore.getRelationshipType(id)) ) continue; - const user = await UserUtils.fetchUser(id).catch(() => void 0); + const user = await UserUtils.getUser(id).catch(() => void 0); if (user) notify( `Friend request from ${getUniqueUsername(user)} has been revoked.`, diff --git a/src/plugins/serverProfile/GuildProfileModal.tsx b/src/plugins/serverProfile/GuildProfileModal.tsx index 2be9b57d9..2a7958a10 100644 --- a/src/plugins/serverProfile/GuildProfileModal.tsx +++ b/src/plugins/serverProfile/GuildProfileModal.tsx @@ -162,7 +162,7 @@ function Owner(guildId: string, owner: User) { } function ServerInfoTab({ guild }: GuildProps) { - const [owner] = useAwaiter(() => UserUtils.fetchUser(guild.ownerId), { + const [owner] = useAwaiter(() => UserUtils.getUser(guild.ownerId), { deps: [guild.ownerId], fallbackValue: null }); diff --git a/src/utils/discord.tsx b/src/utils/discord.tsx index 458509b42..a36ecfbb9 100644 --- a/src/utils/discord.tsx +++ b/src/utils/discord.tsx @@ -103,7 +103,7 @@ export function openImageModal(url: string, props?: Partial Promise, -}; +export const UserUtils = findByPropsLazy("getUser", "fetchCurrentUser") as { getUser: (id: string) => Promise; }; export const Clipboard = mapMangledModuleLazy('document.queryCommandEnabled("copy")||document.queryCommandSupported("copy")', { copy: filters.byCode(".copy("), From e69236c5f83c935b8e00658928536cae380a8776 Mon Sep 17 00:00:00 2001 From: Nico Date: Wed, 25 Oct 2023 16:58:02 +0200 Subject: [PATCH 049/128] fix(vcDoubleClick): update for new discord build (#1862) --- src/plugins/vcDoubleClick/index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/vcDoubleClick/index.ts b/src/plugins/vcDoubleClick/index.ts index 31543510e..a55ac7b67 100644 --- a/src/plugins/vcDoubleClick/index.ts +++ b/src/plugins/vcDoubleClick/index.ts @@ -30,20 +30,22 @@ export default definePlugin({ description: "Join voice chats via double click instead of single click", authors: [Devs.Ven, Devs.D3SOX], patches: [ - { - find: "VoiceChannel.renderPopout", + ...[ + ".handleVoiceStatusClick", // voice channels + ".handleClickChat" // stage channels + ].map(find => ({ + find, // hack: these are not React onClick, it is a custom prop handled by Discord // thus, replacing this with onDoubleClick won't work, and you also cannot check // e.detail since instead of the event they pass the channel. // do this timer workaround instead replacement: [ - // voice/stage channels { - match: /onClick:function\(\)\{(e\.handleClick.+?)}/g, - replace: "onClick:function(){$self.schedule(()=>{$1},e)}", + match: /onClick:\(\)=>\{this.handleClick\(\)/g, + replace: "onClick:()=>{$self.schedule(()=>{this.handleClick()},this)", }, - ], - }, + ] + })), { // channel mentions find: ".shouldCloseDefaultModals", From cd06980016b2646d4941b3a5bcf24278cd06123f Mon Sep 17 00:00:00 2001 From: megumin Date: Wed, 25 Oct 2023 16:00:24 +0100 Subject: [PATCH 050/128] fix: pronoundb profile popout (#1860) --- src/plugins/pronoundb/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index bd5b2c5a9..6eac86698 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -57,8 +57,8 @@ export default definePlugin({ find: ".userTagNoNickname", replacement: [ { - match: /,(\i)=(\i)\.pronouns/, - replace: ",[$1,vcPronounSource]=$self.useProfilePronouns($2.user.id)" + match: /{user:(\i),[^}]*,pronouns:(\i),[^}]*}=\i;/, + replace: "$&let vcPronounSource;[$2,vcPronounSource]=$self.useProfilePronouns($1.id);" }, PRONOUN_TOOLTIP_PATCH ] From 7de1b5dcb6fea56f53a164894dedebb1cb9de7e3 Mon Sep 17 00:00:00 2001 From: megumin Date: Wed, 25 Oct 2023 16:00:39 +0100 Subject: [PATCH 051/128] fix: sortFriendRequests patches (#1848) --- src/plugins/sortFriendRequests/index.tsx | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index b9732afb8..3698379c8 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -29,26 +29,28 @@ export default definePlugin({ description: "Sorts friend requests by date of receipt", patches: [{ - find: ".PENDING_INCOMING||", - replacement: [{ - match: /\.sortBy\(\(function\((\w)\){return \w{1,3}\.comparator}\)\)/, - // If the row type is 3 or 4 (pendinng incoming or outgoing), sort by date of receipt - // Otherwise, use the default comparator - replace: (_, row) => `.sortBy((function(${row}) { - return ${row}.type === 3 || ${row}.type === 4 - ? -Vencord.Plugins.plugins.SortFriendRequests.getSince(${row}.user) - : ${row}.comparator - }))` - }, { + find: "getRelationshipCounts(){", + replacement: { + match: /\.sortBy\(\i=>\i\.comparator\)/, + replace: ".sortBy((row) => $self.sortList(row))" + } + }, { + find: "RelationshipTypes.PENDING_INCOMING?", + replacement: { predicate: () => Settings.plugins.SortFriendRequests.showDates, - match: /(user:(\w{1,3}),.{10,30}),subText:(\w{1,3}),(.{10,30}userInfo}\))/, - // Show dates in the friend request list - replace: (_, pre, user, subText, post) => `${pre}, - subText: Vencord.Plugins.plugins.SortFriendRequests.makeSubtext(${subText}, ${user}), - ${post}` - }] + match: /(user:(\i),.{10,50}),subText:(\i),(className:\i\.userInfo}\))/, + replace: (_, pre, user, subtext, post) => `${pre}, + subText: $self.makeSubtext(${subtext}, ${user}), + ${post}` + } }], + sortList(row: any) { + return row.type === 3 || row.type === 4 + ? -this.getSince(row.user) + : row.comparator; + }, + getSince(user: User) { return new Date(RelationshipStore.getSince(user.id)); }, From af1aa396479f62bc5e7e9960d133c604606446a1 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 17:03:17 +0200 Subject: [PATCH 052/128] Delete RNNoise - Krisp is now on web, so this is obsolete --- src/plugins/rnnoise.web/icons.tsx | 21 --- src/plugins/rnnoise.web/index.tsx | 250 ----------------------------- src/plugins/rnnoise.web/styles.css | 29 ---- 3 files changed, 300 deletions(-) delete mode 100644 src/plugins/rnnoise.web/icons.tsx delete mode 100644 src/plugins/rnnoise.web/index.tsx delete mode 100644 src/plugins/rnnoise.web/styles.css diff --git a/src/plugins/rnnoise.web/icons.tsx b/src/plugins/rnnoise.web/icons.tsx deleted file mode 100644 index 8fda9839a..000000000 --- a/src/plugins/rnnoise.web/icons.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -export const SupressionIcon = ({ enabled }: { enabled: boolean; }) => enabled - ? - : ; diff --git a/src/plugins/rnnoise.web/index.tsx b/src/plugins/rnnoise.web/index.tsx deleted file mode 100644 index 8de6557e7..000000000 --- a/src/plugins/rnnoise.web/index.tsx +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import "./styles.css"; - -import { definePluginSettings } from "@api/Settings"; -import { classNameFactory } from "@api/Styles"; -import { Switch } from "@components/Switch"; -import { loadRnnoise, RnnoiseWorkletNode } from "@sapphi-red/web-noise-suppressor"; -import { Devs } from "@utils/constants"; -import { rnnoiseWasmSrc, rnnoiseWorkletSrc } from "@utils/dependencies"; -import { makeLazy } from "@utils/lazy"; -import { Logger } from "@utils/Logger"; -import { LazyComponent } from "@utils/react"; -import definePlugin from "@utils/types"; -import { findByCode } from "@webpack"; -import { FluxDispatcher, Popout, React } from "@webpack/common"; -import { MouseEvent, ReactNode } from "react"; - -import { SupressionIcon } from "./icons"; - -const RNNOISE_OPTION = "RNNOISE"; - -interface PanelButtonProps { - tooltipText: string; - icon: () => ReactNode; - onClick: (event: MouseEvent) => void; - tooltipClassName?: string; - disabled?: boolean; - shouldShow?: boolean; -} -const PanelButton = LazyComponent(() => findByCode("Masks.PANEL_BUTTON")); -const enum SpinnerType { - SpinningCircle = "spinningCircle", - ChasingDots = "chasingDots", - LowMotion = "lowMotion", - PulsingEllipsis = "pulsingEllipsis", - WanderingCubes = "wanderingCubes", -} -export interface SpinnerProps { - type: SpinnerType; - animated?: boolean; - className?: string; - itemClassName?: string; -} -const Spinner = LazyComponent(() => findByCode(".spinningCircleInner")); - -function createExternalStore(init: () => S) { - const subscribers = new Set<() => void>(); - let state = init(); - - return { - get: () => state, - set: (newStateGetter: (oldState: S) => S) => { - state = newStateGetter(state); - for (const cb of subscribers) cb(); - }, - use: () => { - return React.useSyncExternalStore(onStoreChange => { - subscribers.add(onStoreChange); - return () => subscribers.delete(onStoreChange); - }, () => state); - }, - } as const; -} - -const cl = classNameFactory("vc-rnnoise-"); - -const loadedStore = createExternalStore(() => ({ - isLoaded: false, - isLoading: false, - isError: false, -})); -const getRnnoiseWasm = makeLazy(() => { - loadedStore.set(s => ({ ...s, isLoading: true })); - return loadRnnoise({ - url: rnnoiseWasmSrc(), - simdUrl: rnnoiseWasmSrc(true), - }).then(buffer => { - // Check WASM magic number cus fetch doesnt throw on 4XX or 5XX - if (new DataView(buffer.slice(0, 4)).getUint32(0) !== 0x0061736D) throw buffer; - - loadedStore.set(s => ({ ...s, isLoaded: true })); - return buffer; - }).catch(error => { - if (error instanceof ArrayBuffer) error = new TextDecoder().decode(error); - logger.error("Failed to load RNNoise WASM:", error); - loadedStore.set(s => ({ ...s, isError: true })); - return null; - }).finally(() => { - loadedStore.set(s => ({ ...s, isLoading: false })); - }); -}); - -const logger = new Logger("RNNoise"); -const settings = definePluginSettings({}).withPrivateSettings<{ isEnabled: boolean; }>(); -const setEnabled = (enabled: boolean) => { - settings.store.isEnabled = enabled; - FluxDispatcher.dispatch({ type: "AUDIO_SET_NOISE_SUPPRESSION", enabled }); -}; - -function NoiseSupressionPopout() { - const { isEnabled } = settings.use(); - const { isLoading, isError } = loadedStore.use(); - const isWorking = isEnabled && !isError; - - return
-
- Noise Supression -
- {isLoading && } - -
-
- Enable AI noise suppression! Make some noise—like becoming an air conditioner, or a vending machine fan—while speaking. Your friends will hear nothing but your beautiful voice ✨ -
-
; -} - -export default definePlugin({ - name: "AI Noise Suppression", - description: "Uses an open-source AI model (RNNoise) to remove background noise from your microphone", - authors: [Devs.Vap], - settings, - enabledByDefault: true, - - patches: [ - { - // Pass microphone stream to RNNoise - find: "window.webkitAudioContext", - replacement: { - match: /(?<=\i\.acquire=function\((\i)\)\{return )navigator\.mediaDevices\.getUserMedia\(\1\)(?=\})/, - replace: "$&.then(stream => $self.connectRnnoise(stream, $1.audio))" - }, - }, - { - // Noise suppression button in call modal - find: "renderNoiseCancellation()", - replacement: { - match: /(?<=(\i)\.jsxs?.{0,70}children:\[)(?=\i\?\i\.renderNoiseCancellation\(\))/, - replace: (_, react) => `${react}.jsx($self.NoiseSupressionButton, {}),` - }, - }, - { - // Give noise suppression component a "shouldShow" prop - find: "Masks.PANEL_BUTTON", - replacement: { - match: /(?<==(\i)\.tooltipForceOpen.{0,100})(?=tooltipClassName:)/, - replace: (_, props) => `shouldShow: ${props}.shouldShow,` - } - }, - { - // Noise suppression option in voice settings - find: "Messages.USER_SETTINGS_NOISE_CANCELLATION_KRISP", - replacement: [{ - match: /(?<=(\i)=\i\?\i\.KRISP:\i.{1,20}?;)/, - replace: (_, option) => `if ($self.isEnabled()) ${option} = ${JSON.stringify(RNNOISE_OPTION)};`, - }, { - match: /(?=\i&&(\i)\.push\(\{name:(?:\i\.){1,2}Messages.USER_SETTINGS_NOISE_CANCELLATION_KRISP)/, - replace: (_, options) => `${options}.push({ name: "AI (RNNoise)", value: "${RNNOISE_OPTION}" });`, - }, { - match: /(?<=onChange:function\((\i)\)\{)(?=(?:\i\.){1,2}setNoiseCancellation)/, - replace: (_, option) => `$self.setEnabled(${option}.value === ${JSON.stringify(RNNOISE_OPTION)});`, - }], - }, - ], - - setEnabled, - isEnabled: () => settings.store.isEnabled, - async connectRnnoise(stream: MediaStream, isAudio: boolean): Promise { - if (!isAudio) return stream; - if (!settings.store.isEnabled) return stream; - - const audioCtx = new AudioContext(); - await audioCtx.audioWorklet.addModule(rnnoiseWorkletSrc); - - const rnnoiseWasm = await getRnnoiseWasm(); - if (!rnnoiseWasm) { - logger.warn("Failed to load RNNoise, noise suppression won't work"); - return stream; - } - - const rnnoise = new RnnoiseWorkletNode(audioCtx, { - wasmBinary: rnnoiseWasm, - maxChannels: 1, - }); - - const source = audioCtx.createMediaStreamSource(stream); - source.connect(rnnoise); - - const dest = audioCtx.createMediaStreamDestination(); - rnnoise.connect(dest); - - // Cleanup - const onEnded = () => { - rnnoise.disconnect(); - source.disconnect(); - audioCtx.close(); - rnnoise.destroy(); - }; - stream.addEventListener("inactive", onEnded, { once: true }); - - return dest.stream; - }, - NoiseSupressionButton(): ReactNode { - const { isEnabled } = settings.use(); - const { isLoading, isError } = loadedStore.use(); - - return } - spacing={8} - > - {(props, { isShown }) => ( -
- -
} - /> - )} -
; - }, -}); diff --git a/src/plugins/rnnoise.web/styles.css b/src/plugins/rnnoise.web/styles.css deleted file mode 100644 index 7945c496a..000000000 --- a/src/plugins/rnnoise.web/styles.css +++ /dev/null @@ -1,29 +0,0 @@ -.vc-rnnoise-popout { - background: var(--background-floating); - border-radius: 0.25em; - padding: 1em; - width: 16em; -} - -.vc-rnnoise-popout-heading { - color: var(--text-normal); - font-weight: 500; - display: flex; - justify-content: space-between; - align-items: center; - font-size: 1.1em; - margin-bottom: 1em; - gap: 0.5em; -} - -.vc-rnnoise-popout-desc { - color: var(--text-muted); - font-size: 0.9em; - display: flex; - align-items: center; - line-height: 1.5; -} - -.vc-rnnoise-tooltip { - text-align: center; -} From cf3c28e1ff32dae2ae3d89338c9a645ae8c96ebd Mon Sep 17 00:00:00 2001 From: Dea Date: Wed, 25 Oct 2023 15:19:09 +0000 Subject: [PATCH 053/128] fix: onePingPerDM (#1867) --- src/plugins/onePingPerDM/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/onePingPerDM/index.ts b/src/plugins/onePingPerDM/index.ts index e69620ae7..37ca87125 100644 --- a/src/plugins/onePingPerDM/index.ts +++ b/src/plugins/onePingPerDM/index.ts @@ -45,11 +45,11 @@ export default definePlugin({ patches: [{ find: ".getDesktopType()===", replacement: [{ - match: /if\((\i\.\i\.getDesktopType\(\)===\i\.\i\.NEVER)\){/, - replace: "if($1){if(!$self.isPrivateChannelRead(arguments[0]?.message))return;" + match: /(\i\.\i\.getDesktopType\(\)===\i\.\i\.NEVER)\)/, + replace: "$&if(!$self.isPrivateChannelRead(arguments[0]?.message))return;else " }, { - match: /sound:(\i\?\i:void 0,volume:\i,onClick:)/, + match: /sound:(\i\?\i:void 0,volume:\i,onClick)/, replace: "sound:!$self.isPrivateChannelRead(arguments[0]?.message)?undefined:$1" }] }], From 8d1561aed4baa9babdb3bcfccfa91e08f7cf7aab Mon Sep 17 00:00:00 2001 From: redstonekasi Date: Wed, 25 Oct 2023 17:19:53 +0200 Subject: [PATCH 054/128] fix: NoticesAPI (#1863) --- src/plugins/_api/notices.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts index af7cb15e8..0648afa04 100644 --- a/src/plugins/_api/notices.ts +++ b/src/plugins/_api/notices.ts @@ -29,12 +29,12 @@ export default definePlugin({ find: 'displayName="NoticeStore"', replacement: [ { - match: /(?=;\i=null;.{0,70}getPremiumSubscription)/g, - replace: ";if(Vencord.Api.Notices.currentNotice)return false" + match: /\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, + replace: "if(Vencord.Api.Notices.currentNotice)return false;$&" }, { - match: /(?<=,NOTICE_DISMISS:function\(\i\){)(?=if\(null==(\i)\))/, - replace: (_, notice) => `if(${notice}.id=="VencordNotice")return(${notice}=null,Vencord.Api.Notices.nextNotice(),true);` + match: /(?<=,NOTICE_DISMISS:function\(\i\){)return null!=(\i)/, + replace: "if($1.id==\"VencordNotice\")return($1=null,Vencord.Api.Notices.nextNotice(),true);$&" } ] } From 3917193e8fee9832e958a71c5109d39cb808c1da Mon Sep 17 00:00:00 2001 From: Syncx <47534062+Syncxv@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:50:11 +0530 Subject: [PATCH 055/128] fix: ImageZoom (#1864) --- src/plugins/imageZoom/index.tsx | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 1f0d7e127..23dcddde7 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -37,13 +37,6 @@ export const settings = definePluginSettings({ default: true, }, - preventCarouselFromClosingOnClick: { - type: OptionType.BOOLEAN, - // Thanks chat gpt - description: "Allow the image modal in the image slideshow thing / carousel to remain open when clicking on the image", - default: true, - }, - invertScroll: { type: OptionType.BOOLEAN, description: "Invert scroll", @@ -163,10 +156,14 @@ export default definePlugin({ patches: [ { - find: '"renderLinkComponent","maxWidth"', + find: "Messages.OPEN_IN_BROWSER", replacement: { - match: /(return\(.{1,100}\(\)\.wrapper.{1,200})(src)/, - replace: `$1id: '${ELEMENT_ID}',$2` + // there are 2 image thingies. one for carosuel and one for the single image. + // so thats why i added global flag. + // also idk if this patch is good, should it be more specific? + // https://regex101.com/r/xfvNvV/1 + match: /return.{1,200}\.wrapper.{1,200}src:\i,/g, + replace: `$&id: '${ELEMENT_ID}',` } }, @@ -174,28 +171,21 @@ export default definePlugin({ find: "handleImageLoad=", replacement: [ { - match: /showThumbhashPlaceholder:/, + match: /showThumbhashPlaceholder:\i,/, replace: "...$self.makeProps(this),$&" }, { - match: /componentDidMount=function\(\){/, + match: /componentDidMount\(\){/, replace: "$&$self.renderMagnifier(this);", }, { - match: /componentWillUnmount=function\(\){/, + match: /componentWillUnmount\(\){/, replace: "$&$self.unMountMagnifier();" } ] }, - { - find: ".carouselModal,", - replacement: { - match: /onClick:(\i),/, - replace: "onClick:$self.settings.store.preventCarouselFromClosingOnClick ? () => {} : $1," - } - } ], settings, From 06b4dffa628d39914eaaaf3358d3d0e63d1811eb Mon Sep 17 00:00:00 2001 From: Nico Date: Wed, 25 Oct 2023 17:26:28 +0200 Subject: [PATCH 056/128] forceOwnerCrown: fix (#1858) --- src/plugins/forceOwnerCrown/index.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/forceOwnerCrown/index.ts b/src/plugins/forceOwnerCrown/index.ts index eaee62840..15b1f6f56 100644 --- a/src/plugins/forceOwnerCrown/index.ts +++ b/src/plugins/forceOwnerCrown/index.ts @@ -27,18 +27,17 @@ export default definePlugin({ authors: [Devs.D3SOX, Devs.Nickyux], patches: [ { - // This is the logic where it decides whether to render the owner crown or not - find: ".MULTIPLE_AVATAR", + find: "AVATAR_DECORATION_PADDING:", replacement: { - match: /(\i)=(\i)\.isOwner,/, - replace: "$1=$self.isGuildOwner($2)," + match: /,isOwner:(\i),/, + replace: ",_isOwner:$1=$self.isGuildOwner(e)," } } ], - isGuildOwner(props: { user: User, channel: Channel, guildId?: string; }) { - if (!props?.user?.id) return false; + isGuildOwner(props: { user: User, channel: Channel, isOwner: boolean, guildId?: string; }) { + if (!props?.user?.id) return props.isOwner; if (props.channel?.type === 3 /* GROUP_DM */) - return false; + return props.isOwner; // guild id is in props twice, fallback if the first is undefined const guildId = props.guildId ?? props.channel?.guild_id; From 131e91a37c7fae071df80817f90791a5d5a63f11 Mon Sep 17 00:00:00 2001 From: redstonekasi Date: Wed, 25 Oct 2023 17:29:07 +0200 Subject: [PATCH 057/128] fix: AlwaysTrust (#1868) --- src/plugins/alwaysTrust/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/alwaysTrust/index.ts b/src/plugins/alwaysTrust/index.ts index 79193b0af..07e92afce 100644 --- a/src/plugins/alwaysTrust/index.ts +++ b/src/plugins/alwaysTrust/index.ts @@ -27,15 +27,15 @@ export default definePlugin({ { find: ".displayName=\"MaskedLinkStore\"", replacement: { - match: /\.isTrustedDomain=function\(.\){return.+?};/, - replace: ".isTrustedDomain=function(){return true};" + match: /(?<=isTrustedDomain\(\i\){)return \i\(\i\)/, + replace: "return true" } }, { - find: '"7z","ade","adp"', + find: "isSuspiciousDownload:", replacement: { - match: /JSON\.parse\('\[.+?'\)/, - replace: "[]" + match: /function \i\(\i\){(?=.{0,60}\.parse\(\i\))/, + replace: "$&return null;" } } ] From c5dd50ad8fbee871b182e3d1203a812d6c43396e Mon Sep 17 00:00:00 2001 From: sunnie <78964224+sunnniee@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:33:22 +0300 Subject: [PATCH 058/128] fix messageLinkEmbeds, moreUserTags (#1859) --- src/plugins/messageLinkEmbeds/index.tsx | 27 +++------- src/plugins/moreUserTags/index.tsx | 69 +++++++++++++------------ src/webpack/common/index.ts | 1 + src/webpack/common/settingsStores.ts | 9 ++++ 4 files changed, 52 insertions(+), 54 deletions(-) create mode 100644 src/webpack/common/settingsStores.ts diff --git a/src/plugins/messageLinkEmbeds/index.tsx b/src/plugins/messageLinkEmbeds/index.tsx index c7b3bd012..e600d737d 100644 --- a/src/plugins/messageLinkEmbeds/index.tsx +++ b/src/plugins/messageLinkEmbeds/index.tsx @@ -18,7 +18,6 @@ import { addAccessory } from "@api/MessageAccessories"; import { definePluginSettings } from "@api/Settings"; -import { getSettingStoreLazy } from "@api/SettingsStore"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants.js"; import { classes } from "@utils/misc"; @@ -36,6 +35,7 @@ import { PermissionStore, RestAPI, Text, + TextAndImagesSettingsStores, UserStore } from "@webpack/common"; import { Channel, Guild, Message } from "discord-types/general"; @@ -46,12 +46,11 @@ const messageCache = new Map(); const Embed = LazyComponent(() => findByCode(".inlineMediaEmbed")); -const ChannelMessage = LazyComponent(() => find(m => m.type?.toString()?.includes('["message","compact","className",'))); +const AutoModEmbed = LazyComponent(() => findByCode(".withFooter]:", "childrenMessageContent:")); +const ChannelMessage = LazyComponent(() => find(m => m.type?.toString()?.includes("renderSimpleAccessories)"))); const SearchResultClasses = findByPropsLazy("message", "searchResult"); -let AutoModEmbed: React.ComponentType = () => null; - const messageLinkRegex = /(?; } -const compactModeEnabled = getSettingStoreLazy("textAndImages", "messageDisplayCompact")!; - function AutomodEmbedAccessory(props: MessageEmbedProps): JSX.Element | null { const { message, channel, guildID } = props; + const compact = TextAndImagesSettingsStores.MessageDisplayCompact.useSetting(); const isDM = guildID === "@me"; const images = getImages(message); const { parse } = Parser; @@ -338,7 +336,7 @@ function AutomodEmbedAccessory(props: MessageEmbedProps): JSX.Element | null { {isDM ? " - Direct Message" : " - " + GuildStore.getGuild(channel.guild_id)?.name} } - compact={compactModeEnabled.getSetting()} + compact={compact} content={ <> {message.content || message.attachments.length <= images.length @@ -365,20 +363,7 @@ export default definePlugin({ name: "MessageLinkEmbeds", description: "Adds a preview to messages that link another message", authors: [Devs.TheSun, Devs.Ven, Devs.RyanCaoDev], - dependencies: ["MessageAccessoriesAPI", "SettingsStoreAPI"], - patches: [ - { - find: ".embedCard", - replacement: [{ - match: /function (\i)\(\i\){var \i=\i\.message,\i=\i\.channel.{0,200}\.hideTimestamp/, - replace: "$self.AutoModEmbed=$1;$&" - }] - } - ], - - set AutoModEmbed(e: any) { - AutoModEmbed = e; - }, + dependencies: ["MessageAccessoriesAPI"], settings, diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index c8820f8be..9921bca8e 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -22,7 +22,7 @@ import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy, findLazy } from "@webpack"; -import { Card, ChannelStore, Forms, GuildStore, Switch, TextInput, Tooltip, useState } from "@webpack/common"; +import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common"; import { RC } from "@webpack/types"; import { Channel, Message, User } from "discord-types/general"; @@ -58,7 +58,6 @@ const PermissionUtil = findByPropsLazy("computePermissions", "canEveryoneRole") computePermissions({ ...args }): bigint; }; -const Permissions = findByPropsLazy("SEND_MESSAGES", "VIEW_CREATOR_MONETIZATION_ANALYTICS") as Record; const Tag = findLazy(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record; }; const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot(); @@ -188,17 +187,14 @@ export default definePlugin({ patches: [ // add tags to the tag list { - find: '.BOT=0]="BOT"', - replacement: [ - // add tags to the exported tags list (Tag.Types) - { - match: /(\i)\[.\.BOT=0\]="BOT";/, - replace: "$&$1=$self.addTagVariants($1);" - } - ] + find: "BotTagTypes:", + replacement: { + match: /\((\i)=\{\}\)\)\[(\i)\.BOT/, + replace: "($1=$self.getTagTypes()))[$2.BOT" + } }, { - find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP;", + find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP,", replacement: [ // make the tag show the right text { @@ -213,25 +209,25 @@ export default definePlugin({ }, // add HTML data attributes (for easier theming) { - match: /children:\[(?=\i\?null:\i,\i,\(0,\i\.jsx\)\("span",{className:\i\(\)\.botText,children:(\i)}\)\])/, - replace: "'data-tag':$1.toLowerCase(),children:[" + match: /.botText,children:(\i)}\)]/, + replace: "$&,'data-tag':$1.toLowerCase()" } ], }, // in messages { - find: ".Types.ORIGINAL_POSTER", + find: "renderSystemTag:", replacement: { - match: /return null==(\i)\?null:\(0,/, - replace: "$1=$self.getTag({...arguments[0],origType:$1,location:'chat'});$&" + match: /;return\((\(null==\i\?void 0:\i\.isSystemDM\(\).+?.Types.ORIGINAL_POSTER\)),null==(\i)\)/, + replace: ";$1;$2=$self.getTag({...arguments[0],origType:$2,location:'chat'});return $2 == null" } }, // in the member list { find: ".Messages.GUILD_OWNER,", replacement: { - match: /(?\i)=\(null==.{0,50}\.BOT,null!=(?\i)&&\i\.bot/, - replace: "$ = $self.getTag({user: $, channel: arguments[0].channel, origType: $.bot ? 0 : null, location: 'not-chat' }), typeof $ === 'number'" + match: /(?\i)=\(null==.{0,100}\.BOT;return null!=(?\i)&&\i\.bot/, + replace: "$ = $self.getTag({user: $, channel: arguments[0].channel, origType: $.bot ? 0 : null, location: 'not-chat' }); return typeof $ === 'number'" } }, // pass channel id down props to be used in profiles @@ -251,11 +247,18 @@ export default definePlugin({ }, // in profiles { - find: "showStreamerModeTooltip:", - replacement: { - match: /,botType:(\i\((\i)\)),/g, - replace: ",botType:$self.getTag({user:$2,channelId:arguments[0].moreTags_channelId,origType:$1,location:'not-chat'})," - } + find: ",overrideDiscriminator:", + replacement: [ + { + // prevent channel id from getting ghosted + // it's either this or extremely long lookbehind + match: /user:\i,nick:\i,/, + replace: "$&moreTags_channelId," + }, { + match: /,botType:(\i\((\i)\)),/g, + replace: ",botType:$self.getTag({user:$2,channelId:moreTags_channelId,origType:$1,location:'not-chat'})," + } + ] }, ], @@ -295,24 +298,25 @@ export default definePlugin({ if (!guild) return []; const permissions = PermissionUtil.computePermissions({ user, context: guild, overwrites: channel.permissionOverwrites }); - return Object.entries(Permissions) + return Object.entries(PermissionsBits) .map(([perm, permInt]) => permissions & permInt ? perm : "" ) .filter(Boolean); }, - addTagVariants(tagConstant) { + getTagTypes() { + const obj = {}; let i = 100; tags.forEach(({ name }) => { - tagConstant[name] = ++i; - tagConstant[i] = name; - tagConstant[`${name}-BOT`] = ++i; - tagConstant[i] = `${name}-BOT`; - tagConstant[`${name}-OP`] = ++i; - tagConstant[i] = `${name}-OP`; + obj[name] = ++i; + obj[i] = name; + obj[`${name}-BOT`] = ++i; + obj[i] = `${name}-BOT`; + obj[`${name}-OP`] = ++i; + obj[i] = `${name}-OP`; }); - return tagConstant; + return obj; }, isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), @@ -377,7 +381,6 @@ export default definePlugin({ break; } } - return type; } }); diff --git a/src/webpack/common/index.ts b/src/webpack/common/index.ts index 2ad9c54ec..5da3cc68b 100644 --- a/src/webpack/common/index.ts +++ b/src/webpack/common/index.ts @@ -20,6 +20,7 @@ export * from "./classes"; export * from "./components"; export * from "./menu"; export * from "./react"; +export * from "./settingsStores"; export * from "./stores"; export * as ComponentTypes from "./types/components.d"; export * as MenuTypes from "./types/menu.d"; diff --git a/src/webpack/common/settingsStores.ts b/src/webpack/common/settingsStores.ts new file mode 100644 index 000000000..ab281e569 --- /dev/null +++ b/src/webpack/common/settingsStores.ts @@ -0,0 +1,9 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { findByPropsLazy } from "@webpack"; + +export const TextAndImagesSettingsStores = findByPropsLazy("MessageDisplayCompact"); From 9c60b38acc13c7fe6b5334beaadfe36288ad825d Mon Sep 17 00:00:00 2001 From: rini Date: Wed, 25 Oct 2023 12:34:23 -0300 Subject: [PATCH 059/128] Fix PinDMs, SMYN, SilentTyping, ValidUser, PlatformIndicators (#1865) --- src/plugins/_api/memberListDecorators.ts | 15 ++++--------- src/plugins/_api/messageDecorations.ts | 2 +- src/plugins/pinDms/index.tsx | 28 ++++++++++++------------ src/plugins/showMeYourName/index.tsx | 28 +++++++----------------- src/plugins/silentTyping/index.tsx | 6 ++--- src/plugins/validUser/index.tsx | 11 ++++------ 6 files changed, 34 insertions(+), 56 deletions(-) diff --git a/src/plugins/_api/memberListDecorators.ts b/src/plugins/_api/memberListDecorators.ts index bf7377e85..1251c3578 100644 --- a/src/plugins/_api/memberListDecorators.ts +++ b/src/plugins/_api/memberListDecorators.ts @@ -38,17 +38,10 @@ export default definePlugin({ }, { find: "PrivateChannel.renderAvatar", - replacement: [ - // props are shadowed by nested props so we have to do this - { - match: /let\{[^}]*applicationStream:\i[^}]*\}=(\i),/, - replace: "$&vencordProps=$1," - }, - { - match: /decorators:(\i\.isSystemDM\(\))\?(.+?):null/, - replace: "decorators:[...(typeof vencordProps=='undefined'?[]:Vencord.Api.MemberListDecorators.__getDecorators(vencordProps)), $1?$2:null]" - } - ] + replacement: { + match: /decorators:(\i\.isSystemDM\(\))\?(.+?):null/, + replace: "decorators:[...Vencord.Api.MemberListDecorators.__getDecorators(arguments[0]), $1?$2:null]" + } } ], }); diff --git a/src/plugins/_api/messageDecorations.ts b/src/plugins/_api/messageDecorations.ts index 3f0fd11db..1646ad645 100644 --- a/src/plugins/_api/messageDecorations.ts +++ b/src/plugins/_api/messageDecorations.ts @@ -25,7 +25,7 @@ export default definePlugin({ authors: [Devs.TheSun], patches: [ { - find: "UsernameDecorationTypes:", + find: '"Message Username"', replacement: { match: /currentUserIsPremium:.{0,70}{children:\i(?=}\))/, replace: "$&.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))" diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index a7406aa41..ac5957b33 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -66,7 +66,7 @@ export default definePlugin({ // filter Discord's privateChannelIds list to remove pins, and pass // pinCount as prop. This needs to be here so that the entire DM list receives // updates on pin/unpin - match: /privateChannelIds:(\i),/, + match: /(?<=\i,{channels:\i,)privateChannelIds:(\i),/, replace: "privateChannelIds:$1.filter(c=>!$self.isPinned(c)),pinCount:$self.usePinCount($1)," }, { @@ -75,39 +75,39 @@ export default definePlugin({ // - Section 1: buttons for pages like Friends & Library // - Section 2: our pinned dms // - Section 3: the normal dm list - match: /(?<=renderRow:(\i)\.renderRow,)sections:\[\i,/, + match: /(?<=renderRow:this\.renderRow,)sections:\[\i,/, // For some reason, adding our sections when no private channels are ready yet // makes DMs infinitely load. Thus usePinCount returns either a single element // array with the count, or an empty array. Due to spreading, only in the former // case will an element be added to the outer array // Thanks for the fix, Strencher! - replace: "$&...($1.props.pinCount ?? [])," + replace: "$&...this.props.pinCount??[]," }, { // Patch renderSection (renders the header) to set the text to "Pinned DMs" instead of "Direct Messages" // lookbehind is used to lookup parameter name. We could use arguments[0], but // if children ever is wrapped in an iife, it will break - match: /children:(\i\.\i\.Messages.DIRECT_MESSAGES)(?<=renderSection=function\((\i)\).+?)/, + match: /children:(\i\.\i\.Messages.DIRECT_MESSAGES)(?<=renderSection=(\i)=>{.+?)/, replace: "children:$2.section===1?'Pinned DMs':$1" }, { // Patch channel lookup inside renderDM // channel=channels[channelIds[row]]; - match: /(?<=preRenderedChildren,(\i)=)((\i)\[\i\[\i\]\]);/, + match: /(?<=renderDM=\((\i),(\i)\)=>{.*?this.state,\i=\i\[\i\],\i=)((\i)\[\i\]);/, // section 1 is us, manually get our own channel // section === 1 ? getChannel(channels, row) : channels[channelIds[row]]; - replace: "arguments[0]===1?$self.getChannel($3,arguments[1]):$2;" + replace: "$1===1?$self.getChannel($4,$2):$3;" }, { // Fix getRowHeight's check for whether this is the DMs section // section === DMS - match: /===\i.DMS&&0/, + match: /===\i\.DMS&&0/, // section -1 === DMS replace: "-1$&" }, { // Override scrollToChannel to properly account for pinned channels - match: /(?<=else\{\i\+=)(\i)\*\(.+?(?=;)/, + match: /(?<=scrollTo\(\{to:\i\}\):\(\i\+=)(\d+)\*\(.+?(?=,)/, replace: "$self.getScrollOffset(arguments[0],$1,this.props.padding,this.state.preRenderedChildren,$&)" } ] @@ -115,19 +115,19 @@ export default definePlugin({ // Fix Alt Up/Down navigation { - find: '"mod+alt+right"', + find: ".Routes.APPLICATION_STORE&&", replacement: { - // channelIds = __OVERLAY__ ? stuff : toArray(getStaticPaths()).concat(toArray(channelIds)) - match: /(?<=(\i)=__OVERLAY__\?\i:.{0,10})\.concat\((.{0,10})\)/, + // channelIds = __OVERLAY__ ? stuff : [...getStaticPaths(),...channelIds)] + match: /(?<=\i=__OVERLAY__\?\i:\[\.\.\.\i\(\),\.\.\.)\i/, // ....concat(pins).concat(toArray(channelIds).filter(c => !isPinned(c))) - replace: ".concat($self.getSnapshot()).concat($2.filter(c=>!$self.isPinned(c)))" + replace: "$self.getSnapshot().concat($&.filter(c=>!$self.isPinned(c)))" } }, // fix alt+shift+up/down { - find: '"alt+shift+down"', + find: ".getFlattenedGuildIds()],", replacement: { - match: /(?<=return \i===\i\.ME\?)\i\.\i\.getPrivateChannelIds\(\)/, + match: /(?<=\i===\i\.ME\?)\i\.\i\.getPrivateChannelIds\(\)/, replace: "$self.getSnapshot().concat($&.filter(c=>!$self.isPinned(c)))" } }, diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index 4ccaeea8e..6986f69f2 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -1,20 +1,8 @@ /* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Sofia Lima - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ + * Vencord, a Discord client mod + * Copyright (c) 2023 rini + * SPDX-License-Identifier: GPL-3.0-or-later + */ import "./styles.css"; @@ -56,13 +44,13 @@ const settings = definePluginSettings({ export default definePlugin({ name: "ShowMeYourName", description: "Display usernames next to nicks, or no nicks at all", - authors: [Devs.dzshn, Devs.TheKodeToad], + authors: [Devs.Rini, Devs.TheKodeToad], patches: [ { - find: ".withMentionPrefix", + find: '"Message Username"', replacement: { - match: /(?<=onContextMenu:\i,children:)\i\+\i/, - replace: "$self.renderUsername(arguments[0])" + match: /(?<=onContextMenu:\i,children:).*?\}/, + replace: "$self.renderUsername(arguments[0])}" } }, ], diff --git a/src/plugins/silentTyping/index.tsx b/src/plugins/silentTyping/index.tsx index a4dc2568d..d4cb27ba4 100644 --- a/src/plugins/silentTyping/index.tsx +++ b/src/plugins/silentTyping/index.tsx @@ -74,13 +74,13 @@ function SilentTypingToggle(chatBoxProps: { export default definePlugin({ name: "SilentTyping", - authors: [Devs.Ven, Devs.dzshn], + authors: [Devs.Ven, Devs.Rini], description: "Hide that you are typing", patches: [ { - find: "startTyping:", + find: '.dispatch({type:"TYPING_START_LOCAL"', replacement: { - match: /startTyping:.+?,stop/, + match: /startTyping\(\i\){.+?},stop/, replace: "startTyping:$self.startTyping,stop" } }, diff --git a/src/plugins/validUser/index.tsx b/src/plugins/validUser/index.tsx index a3862d4d0..b0c77cb46 100644 --- a/src/plugins/validUser/index.tsx +++ b/src/plugins/validUser/index.tsx @@ -21,14 +21,11 @@ import { Devs } from "@utils/constants"; import { sleep } from "@utils/misc"; import { Queue } from "@utils/Queue"; import definePlugin from "@utils/types"; -import { findByCodeLazy } from "@webpack"; -import { UserStore, useState } from "@webpack/common"; -import type { User } from "discord-types/general"; +import { UserStore, UserUtils, useState } from "@webpack/common"; import type { ComponentType, ReactNode } from "react"; const fetching = new Set(); const queue = new Queue(5); -const fetchUser = findByCodeLazy("USER(") as (id: string) => Promise; interface MentionProps { data: { @@ -88,7 +85,7 @@ function MentionWrapper({ data, UserMention, RoleMention, parse, props }: Mentio fetching.add(id); queue.unshift(() => - fetchUser(id) + UserUtils.getUser(id) .then(() => { setUserId(id); fetching.delete(id); @@ -122,9 +119,9 @@ export default definePlugin({ find: 'className:"mention"', replacement: { // mention = { react: function (data, parse, props) { if (data.userId == null) return RoleMention() else return UserMention() - match: /react:(?=function\(\i,\i,\i\).{0,50}return null==\i\?\(0,\i\.jsx\)\((\i),.+?jsx\)\((\i),\{className:"mention")/, + match: /react(?=\(\i,\i,\i\).{0,50}return null==\i\?\(0,\i\.jsx\)\((\i\.\i),.+?jsx\)\((\i\.\i),\{className:"mention")/, // react: (...args) => OurWrapper(RoleMention, UserMention, ...args), originalReact: theirFunc - replace: "react:(...args)=>$self.renderMention($1,$2,...args),originalReact:" + replace: "react:(...args)=>$self.renderMention($1,$2,...args),originalReact" } }], From b659d4e9c1f350769284a4dc2d983aeb942c9e7a Mon Sep 17 00:00:00 2001 From: Syncx <47534062+Syncxv@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:05:50 +0530 Subject: [PATCH 060/128] fix: FavoriteEmojiFirst (#1844) --- src/plugins/favEmojiFirst/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/favEmojiFirst/index.ts b/src/plugins/favEmojiFirst/index.ts index fec0b045d..f34b13884 100644 --- a/src/plugins/favEmojiFirst/index.ts +++ b/src/plugins/favEmojiFirst/index.ts @@ -39,22 +39,27 @@ export default definePlugin({ description: "Puts your favorite emoji first in the emoji autocomplete.", patches: [ { - find: ".activeCommandOption", + find: "renderResults({results:", replacement: [ { - // = someFunc(a.selectedIndex); ...trackEmojiSearch({ state: theState, isInPopoutExperimental: someBool }) - match: /=\i\(\i\.selectedIndex\);(?=.+?state:(\i),isInPopoutExperiment:\i)/, - // self.sortEmojis(theState) - replace: "$&$self.sortEmojis($1);" + // https://regex101.com/r/N7kpLM/1 + match: /let \i=.{1,100}renderResults\({results:(\i)\.query\.results,/, + replace: "$self.sortEmojis($1);$&" }, + ], + }, + { + find: "MAX_AUTOCOMPLETE_RESULTS+", + replacement: [ // set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10 // and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later { + // https://regex101.com/r/x2mobQ/1 // searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length) - match: /,maxCount:(\i)(.+?)=(\i)\.slice\(0,(\1-\i\.length)\)/, + match: /,maxCount:(\i)(.{1,500}\i)=(\i)\.slice\(0,(\i-\i\.length)\)/, // ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis) - replace: ",maxCount:Infinity$2=($3.sliceTo=$4,$3)" + replace: ",maxCount:Infinity$2=($3.sliceTo = $4, $3)" } ] } From 3bd657611cbc6b3cf3142ae59c39713922d167df Mon Sep 17 00:00:00 2001 From: redstonekasi Date: Wed, 25 Oct 2023 17:36:19 +0200 Subject: [PATCH 061/128] fix: StartupTimings (#1869) --- src/plugins/startupTimings/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/startupTimings/index.tsx b/src/plugins/startupTimings/index.tsx index 3eec9d0cd..c7417f0fc 100644 --- a/src/plugins/startupTimings/index.tsx +++ b/src/plugins/startupTimings/index.tsx @@ -25,9 +25,9 @@ export default definePlugin({ description: "Adds Startup Timings to the Settings menu", authors: [Devs.Megu], patches: [{ - find: "PAYMENT_FLOW_MODAL_TEST_PAGE,", + find: "UserSettingsSections.PAYMENT_FLOW_MODAL_TEST_PAGE,", replacement: { - match: /{section:.{1,2}\..{1,3}\.PAYMENT_FLOW_MODAL_TEST_PAGE/, + match: /{section:\i\.UserSettingsSections\.PAYMENT_FLOW_MODAL_TEST_PAGE/, replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&' } }], From 1130521e4b2e5f5f06bab458767224dca44b3b33 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 18:07:12 +0200 Subject: [PATCH 062/128] Fix WebContextMenus --- src/plugins/webContextMenus.web/index.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index 26ae19c5d..cd31e7aa8 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -98,8 +98,8 @@ export default definePlugin({ replacement: [ { // if (!IS_WEB || null == - match: /if\(!\i\.\i\|\|null==/, - replace: "if(null==" + match: /!\i\.isPlatformEmbedded/, + replace: "false" }, { match: /return\s*?\[\i\.\i\.canCopyImage\(\)/, @@ -132,23 +132,22 @@ export default definePlugin({ find: '"interactionUsernameProfile"', predicate: () => settings.store.addBack, replacement: { - match: /if\("A"===\i\.tagName&&""!==\i\.textContent\)/, - replace: "if(false)" + match: /if\((?="A"===\i\.tagName&&""!==\i\.textContent)/, + replace: "if(false&&" } }, // Add back slate / text input context menu { - find: '"slate-toolbar"', + find: 'getElementById("slate-toolbar"', predicate: () => settings.store.addBack, replacement: { - match: /(?<=\.handleContextMenu=.+?"bottom";)\i\.\i\?/, - replace: "true?" + match: /(?<=handleContextMenu\(\i\)\{.{0,200}isPlatformEmbedded)\?/, + replace: "||true?" } }, { find: 'navId:"textarea-context"', - all: true, predicate: () => settings.store.addBack, replacement: [ { @@ -167,7 +166,7 @@ export default definePlugin({ find: '"add-to-dictionary"', predicate: () => settings.store.addBack, replacement: { - match: /var \i=\i\.text,/, + match: /let\{text:\i=""/, replace: "return [null,null];$&" } } From 024a77c577cb7b082c46ce24b0ee33851abface9 Mon Sep 17 00:00:00 2001 From: Jack Matthews Date: Wed, 25 Oct 2023 11:48:17 -0400 Subject: [PATCH 063/128] fix: typingIndicator --- src/plugins/typingIndicator/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index 5f7df4770..8ac344606 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -26,7 +26,12 @@ import { ChannelStore, GuildMemberStore, RelationshipStore, Tooltip, UserStore, import { buildSeveralUsers } from "../typingTweaks"; -const ThreeDots = LazyComponent(() => find(m => m.type?.render?.toString()?.includes("().dots"))); +const ThreeDots = LazyComponent(() => { + // This doesn't really need to explicitly find Dots' own module, but it's fine + const res = find(m => m.Dots && !m.Menu); + + return res?.Dots; +}); const TypingStore = findStoreLazy("TypingStore"); const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); @@ -126,8 +131,8 @@ export default definePlugin({ { find: ".UNREAD_HIGHLIGHT", replacement: { - match: /\(\).children.+?:null(?<=(\i)=\i\.channel,.+?)/, - replace: (m, channel) => `${m},$self.TypingIndicator(${channel}.id)` + match: /channel:(\i).{0,100}?channelEmoji,.{0,250}?\.children.{0,50}?:null/, + replace: "$&,$self.TypingIndicator($1.id)" } } ], From 4f8c75372cd63f891f21452f6144823a646c26f6 Mon Sep 17 00:00:00 2001 From: redstonekasi Date: Wed, 25 Oct 2023 18:09:04 +0200 Subject: [PATCH 064/128] fix: NoBlockedMessages (#1870) --- src/plugins/noBlockedMessages/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 54bb2d051..f9de3e13c 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -29,11 +29,11 @@ export default definePlugin({ authors: [Devs.rushii, Devs.Samu], patches: [ { - find: 'safety_prompt:"DMSpamExperiment",response:"show_redacted_messages"', + find: "Messages.BLOCKED_MESSAGES_HIDE", replacement: [ { - match: /\.collapsedReason;return/, - replace: ".collapsedReason;return null;return;" + match: /let\{[^}]*collapsedReason[^}]*\}/, + replace: "return null;$&" } ] }, From ddc39fe84d8b382bf2b5aa93b52c21fc4636330b Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 25 Oct 2023 18:15:12 +0200 Subject: [PATCH 065/128] Fix SettingStores, GameActivityToggle --- src/api/SettingsStore.ts | 69 ------------------------ src/api/index.ts | 5 -- src/plugins/_api/settingsStore.ts | 38 ------------- src/plugins/gameActivityToggle/index.tsx | 10 ++-- src/plugins/gameActivityToggle/style.css | 2 +- src/plugins/ignoreActivities/index.tsx | 7 +-- src/webpack/common/settingsStores.ts | 1 + 7 files changed, 8 insertions(+), 124 deletions(-) delete mode 100644 src/api/SettingsStore.ts delete mode 100644 src/plugins/_api/settingsStore.ts diff --git a/src/api/SettingsStore.ts b/src/api/SettingsStore.ts deleted file mode 100644 index d9369a956..000000000 --- a/src/api/SettingsStore.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { proxyLazy } from "@utils/lazy"; -import { Logger } from "@utils/Logger"; -import { findModuleId, wreq } from "@webpack"; - -import { Settings } from "./Settings"; - -interface Setting { - /** - * Get the setting value - */ - getSetting(): T; - /** - * Update the setting value - * @param value The new value - */ - updateSetting(value: T | ((old: T) => T)): Promise; - /** - * React hook for automatically updating components when the setting is updated - */ - useSetting(): T; - settingsStoreApiGroup: string; - settingsStoreApiName: string; -} - -const SettingsStores: Array> | undefined = proxyLazy(() => { - const modId = findModuleId('"textAndImages","renderSpoilers"'); - if (modId == null) return new Logger("SettingsStoreAPI").error("Didn't find stores module."); - - const mod = wreq(modId); - if (mod == null) return; - - return Object.values(mod).filter((s: any) => s?.settingsStoreApiGroup) as any; -}); - -/** - * Get the store for a setting - * @param group The setting group - * @param name The name of the setting - */ -export function getSettingStore(group: string, name: string): Setting | undefined { - if (!Settings.plugins.SettingsStoreAPI.enabled) throw new Error("Cannot use SettingsStoreAPI without setting as dependency."); - - return SettingsStores?.find(s => s?.settingsStoreApiGroup === group && s?.settingsStoreApiName === name); -} - -/** - * getSettingStore but lazy - */ -export function getSettingStoreLazy(group: string, name: string) { - return proxyLazy(() => getSettingStore(group, name)); -} diff --git a/src/api/index.ts b/src/api/index.ts index f2c47e559..08f238104 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -29,7 +29,6 @@ import * as $Notices from "./Notices"; import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; -import * as $SettingsStore from "./SettingsStore"; import * as $Styles from "./Styles"; /** @@ -91,10 +90,6 @@ export const MemberListDecorators = $MemberListDecorators; * An API allowing you to persist data */ export const Settings = $Settings; -/** - * An API allowing you to read, manipulate and automatically update components based on Discord settings - */ -export const SettingsStore = $SettingsStore; /** * An API allowing you to dynamically load styles * a diff --git a/src/plugins/_api/settingsStore.ts b/src/plugins/_api/settingsStore.ts deleted file mode 100644 index ca1dc65bf..000000000 --- a/src/plugins/_api/settingsStore.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "SettingsStoreAPI", - description: "Patches Discord's SettingsStores to expose their group and name", - authors: [Devs.Nuckyz], - - patches: [ - { - find: '"textAndImages","renderSpoilers"', - replacement: [ - { - match: /(?<=INFREQUENT_USER_ACTION.{0,20}),useSetting:function/, - replace: ",settingsStoreApiGroup:arguments[0],settingsStoreApiName:arguments[1]$&" - } - ] - } - ] -}); diff --git a/src/plugins/gameActivityToggle/index.tsx b/src/plugins/gameActivityToggle/index.tsx index 40318c023..735f124c5 100644 --- a/src/plugins/gameActivityToggle/index.tsx +++ b/src/plugins/gameActivityToggle/index.tsx @@ -16,16 +16,15 @@ * along with this program. If not, see . */ -import { getSettingStoreLazy } from "@api/SettingsStore"; import { disableStyle, enableStyle } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { findByCodeLazy } from "@webpack"; +import { StatusSettingsStores } from "@webpack/common"; import style from "./style.css?managed"; -const ShowCurrentGame = getSettingStoreLazy("status", "showCurrentGame"); const Button = findByCodeLazy("Button.Sizes.NONE,disabled:"); function makeIcon(showCurrentGame?: boolean) { @@ -40,7 +39,7 @@ function makeIcon(showCurrentGame?: boolean) { {!showCurrentGame && <> - + } @@ -50,7 +49,7 @@ function makeIcon(showCurrentGame?: boolean) { } function GameActivityToggleButton() { - const showCurrentGame = ShowCurrentGame?.useSetting(); + const showCurrentGame = StatusSettingsStores.ShowCurrentGame.useSetting(); return (