From 510bfb8fa32ca3b94bd17e57d57b4d658838adde Mon Sep 17 00:00:00 2001 From: maisy Date: Sat, 9 Dec 2023 20:36:58 +0000 Subject: [PATCH 01/23] ReactErrorDecoder: fix using wrong react version's error map (#2040) Co-authored-by: V --- src/plugins/reactErrorDecoder/index.ts | 9 +++++---- src/utils/constants.ts | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/reactErrorDecoder/index.ts b/src/plugins/reactErrorDecoder/index.ts index 2332d457c..9e2e5dc50 100644 --- a/src/plugins/reactErrorDecoder/index.ts +++ b/src/plugins/reactErrorDecoder/index.ts @@ -18,27 +18,28 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; +import { React } from "@webpack/common"; let ERROR_CODES: any; -const CODES_URL = - "https://raw.githubusercontent.com/facebook/react/17.0.2/scripts/error-codes/codes.json"; export default definePlugin({ name: "ReactErrorDecoder", description: 'Replaces "Minifed React Error" with the actual error.', - authors: [Devs.Cyn], + authors: [Devs.Cyn, Devs.maisymoe], patches: [ { find: '"https://reactjs.org/docs/error-decoder.html?invariant="', replacement: { match: /(function .\(.\)){(for\(var .="https:\/\/reactjs\.org\/docs\/error-decoder\.html\?invariant="\+.,.=1;. - `${func}{var decoded=Vencord.Plugins.plugins.ReactErrorDecoder.decodeError.apply(null, arguments);if(decoded)return decoded;${original}}`, + `${func}{var decoded=$self.decodeError.apply(null, arguments);if(decoded)return decoded;${original}}`, }, }, ], async start() { + const CODES_URL = `https://raw.githubusercontent.com/facebook/react/v${React.version}/scripts/error-codes/codes.json`; + ERROR_CODES = await fetch(CODES_URL) .then(res => res.json()) .catch(e => console.error("[ReactErrorDecoder] Failed to fetch React error codes\n", e)); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 1c477b124..2962df06f 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -395,6 +395,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Korbo", id: 455856406420258827n }, + maisymoe: { + name: "maisy", + id: 257109471589957632n, + }, } satisfies Record); // iife so #__PURE__ works correctly From 799e6e7292c9ce2e5c678c0efeda1eadab2721be Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sun, 10 Dec 2023 03:37:24 +0700 Subject: [PATCH 02/23] platformIndicators: fix (#2038) --- src/plugins/platformIndicators/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index 2972b4a46..9fae9adfa 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -55,13 +55,13 @@ const Icons = { }; type Platform = keyof typeof Icons; -const StatusUtils = findByPropsLazy("getStatusColor", "StatusTypes"); +const StatusUtils = findByPropsLazy("useStatusFillColor", "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 539e538d87034b93d06100f2c60a851b12fea694 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 7 Dec 2023 03:28:07 -0300 Subject: [PATCH 03/23] commandHelpers: use MessageActions import --- src/api/Commands/commandHelpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/Commands/commandHelpers.ts b/src/api/Commands/commandHelpers.ts index 2fd189032..8f4a88e4b 100644 --- a/src/api/Commands/commandHelpers.ts +++ b/src/api/Commands/commandHelpers.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { MessageActions } from "@utils/discord"; import { mergeDefaults } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; import { SnowflakeUtils } from "@webpack/common"; @@ -25,7 +26,6 @@ import type { PartialDeep } from "type-fest"; import { Argument } from "./types"; const MessageCreator = findByPropsLazy("createBotMessage"); -const MessageSender = findByPropsLazy("receiveMessage"); export function generateId() { return `-${SnowflakeUtils.fromTimestamp(Date.now())}`; @@ -40,7 +40,7 @@ export function generateId() { export function sendBotMessage(channelId: string, message: PartialDeep): Message { const botMessage = MessageCreator.createBotMessage({ channelId, content: "", embeds: [] }); - MessageSender.receiveMessage(channelId, mergeDefaults(message, botMessage)); + MessageActions.receiveMessage(channelId, mergeDefaults(message, botMessage)); return message as Message; } From a9568bc0552ef0cac57c24da453af4033e692bcb Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:15:29 -0300 Subject: [PATCH 04/23] reporter: fix bad logic --- scripts/generateReport.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index a75a5985f..54db96e66 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -335,15 +335,15 @@ function runTime(token: string) { await (wreq as any).el(sym); delete Object.prototype[sym]; - const validChunksEntryPoints = [] as string[]; - const validChunks = [] as string[]; - const invalidChunks = [] as string[]; + const validChunksEntryPoints = new Set(); + const validChunks = new Set(); + const invalidChunks = new Set(); if (!chunks) throw new Error("Failed to get chunks"); - chunksLoop: for (const entryPoint in chunks) { const chunkIds = chunks[entryPoint]; + let invalidEntryPoint = false; for (const id of chunkIds) { if (!wreq.u(id)) continue; @@ -353,14 +353,16 @@ function runTime(token: string) { .then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); if (isWasm) { - invalidChunks.push(id); - continue chunksLoop; + invalidChunks.add(id); + invalidEntryPoint = true; + continue; } - validChunks.push(id); + validChunks.add(id); } - validChunksEntryPoints.push(entryPoint); + if (!invalidEntryPoint) + validChunksEntryPoints.add(entryPoint); } for (const entryPoint of validChunksEntryPoints) { @@ -373,7 +375,7 @@ function runTime(token: string) { const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record | null; if (!allChunks) throw new Error("Failed to get all chunks"); const chunksLeft = Object.keys(allChunks).filter(id => { - return !(validChunks.includes(id) || invalidChunks.includes(id)); + return !(validChunks.has(id) || invalidChunks.has(id)); }); for (const id of chunksLeft) { From c9f7cf75405bc08f660d3879ed5af7f0b4e1cf68 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:34:58 -0300 Subject: [PATCH 05/23] ci: test all branches --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a756681c2..d4746d673 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,6 @@ name: test on: push: - branches: - - main - - dev pull_request: branches: - main From 6d911790e97f948e6357bb02c17ee4ee73fa5ff1 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sun, 10 Dec 2023 08:05:40 +0700 Subject: [PATCH 06/23] oneko: allow oneko in reduced motion (#2018) --- src/plugins/oneko/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/oneko/index.ts b/src/plugins/oneko/index.ts index c5de470e1..90a3901a7 100644 --- a/src/plugins/oneko/index.ts +++ b/src/plugins/oneko/index.ts @@ -28,7 +28,8 @@ export default definePlugin({ start() { fetch("https://raw.githubusercontent.com/adryd325/oneko.js/8fa8a1864aa71cd7a794d58bc139e755e96a236c/oneko.js") .then(x => x.text()) - .then(s => s.replace("./oneko.gif", "https://raw.githubusercontent.com/adryd325/oneko.js/14bab15a755d0e35cd4ae19c931d96d306f99f42/oneko.gif")) + .then(s => s.replace("./oneko.gif", "https://raw.githubusercontent.com/adryd325/oneko.js/14bab15a755d0e35cd4ae19c931d96d306f99f42/oneko.gif") + .replace("(isReducedMotion)", "(false)")) .then(eval); }, From 1df0b571af6c2c122033fa75889caff1f9193889 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 12 Dec 2023 22:56:01 -0300 Subject: [PATCH 07/23] Fix broken patches --- src/plugins/fakeNitro/index.ts | 2 +- src/plugins/showHiddenChannels/index.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/fakeNitro/index.ts b/src/plugins/fakeNitro/index.ts index 3ac755567..957771887 100644 --- a/src/plugins/fakeNitro/index.ts +++ b/src/plugins/fakeNitro/index.ts @@ -359,7 +359,7 @@ export default definePlugin({ }, // Separate patch for allowing using custom app icons { - find: "location:\"AppIconHome\"", + find: ".FreemiumAppIconIds.DEFAULT&&(", replacement: { match: /\i\.\i\.isPremium\(\i\.\i\.getCurrentUser\(\)\)/, replace: "true" diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index f242146c9..906bed504 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -77,7 +77,7 @@ export default definePlugin({ }, // Do not check for unreads when selecting the render level if the channel is hidden { - match: /(?=!\(0,\i\.getHasImportantUnread\)\(this\.record\))/, + match: /(?<=&&)(?=!\i\.\i\.hasUnread\(this\.record\.id\))/, replace: "$self.isHiddenChannel(this.record)||" }, // Make channels we dont have access to be the same level as normal ones @@ -334,12 +334,12 @@ export default definePlugin({ replacement: [ { // Remove the divider and the open chat button for the HiddenChannelLockScreen - match: /"more-options-popout"\)\),(?<=let{channel:(\i).+?inCall:(\i).+?)/, + match: /"more-options-popout"\)\),(?<=channel:(\i).+?inCall:(\i).+?)/, replace: (m, channel, inCall) => `${m}${inCall}||!$self.isHiddenChannel(${channel},true)&&` }, { // Remove invite users button for the HiddenChannelLockScreen - match: /"popup".{0,100}?if\((?<=let{channel:(\i).+?inCall:(\i).+?)/, + match: /"popup".{0,100}?if\((?<=channel:(\i).+?inCall:(\i).+?)/, replace: (m, channel, inCall) => `${m}(${inCall}||!$self.isHiddenChannel(${channel},true))&&` }, ] From c86de3299ec780b4139b3eeb749673e2f3e7380a Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 12 Dec 2023 23:26:17 -0300 Subject: [PATCH 08/23] fixAll.eslint: `true` -> `"explicit"` --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 426ff6801..fa543b38c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "[typescript]": { "editor.defaultFormatter": "vscode.typescript-language-features" From 817cb9b60bff2fc2c84e8ba27408f698a34e3e9b Mon Sep 17 00:00:00 2001 From: ruukulada <126130342+ruukulada@users.noreply.github.com> Date: Tue, 12 Dec 2023 21:40:13 -0500 Subject: [PATCH 09/23] GameActivityToggle: Icon cleanup (#2041) --- src/plugins/gameActivityToggle/index.tsx | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/plugins/gameActivityToggle/index.tsx b/src/plugins/gameActivityToggle/index.tsx index 2b84d26f1..99cee5b1c 100644 --- a/src/plugins/gameActivityToggle/index.tsx +++ b/src/plugins/gameActivityToggle/index.tsx @@ -28,21 +28,22 @@ import style from "./style.css?managed"; const Button = findComponentByCodeLazy("Button.Sizes.NONE,disabled:"); function makeIcon(showCurrentGame?: boolean) { + const controllerIcon = "M3.06 20.4q-1.53 0-2.37-1.065T.06 16.74l1.26-9q.27-1.8 1.605-2.97T6.06 3.6h11.88q1.8 0 3.135 1.17t1.605 2.97l1.26 9q.21 1.53-.63 2.595T20.94 20.4q-.63 0-1.17-.225T18.78 19.5l-2.7-2.7H7.92l-2.7 2.7q-.45.45-.99.675t-1.17.225Zm14.94-7.2q.51 0 .855-.345T19.2 12q0-.51-.345-.855T18 10.8q-.51 0-.855.345T16.8 12q0 .51.345 .855T18 13.2Zm-2.4-3.6q.51 0 .855-.345T16.8 8.4q0-.51-.345-.855T15.6 7.2q-.51 0-.855.345T14.4 8.4q0 .51.345 .855T15.6 9.6ZM6.9 13.2h1.8v-2.1h2.1v-1.8h-2.1v-2.1h-1.8v2.1h-2.1v1.8h2.1v2.1Z"; return function () { return ( - - - {!showCurrentGame && <> - - - - - - } + + {showCurrentGame ? ( + + ) : ( + <> + + + + + + + + )} ); }; From 40b3ec57ce87752d7d2ed09f4fc36e423207ec7e Mon Sep 17 00:00:00 2001 From: sappho Date: Wed, 13 Dec 2023 04:37:31 -0500 Subject: [PATCH 10/23] FakeNitro: fix non apng gif stickers being sent as images (#2050) --- src/plugins/fakeNitro/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/fakeNitro/index.ts b/src/plugins/fakeNitro/index.ts index 957771887..6107df00e 100644 --- a/src/plugins/fakeNitro/index.ts +++ b/src/plugins/fakeNitro/index.ts @@ -787,7 +787,14 @@ export default definePlugin({ if (sticker.available !== false && (canUseStickers || sticker.guild_id === guildId)) break stickerBypass; - const link = this.getStickerLink(sticker.id); + // [12/12/2023] + // Work around an annoying bug where getStickerLink will return StickerType.GIF, + // but will give us a normal non animated png for no reason + // TODO: Remove this workaround when it's not needed anymore + let link = this.getStickerLink(sticker.id); + if (sticker.format_type === StickerType.GIF && link.includes(".png")) { + link = link.replace(".png", ".gif"); + } if (sticker.format_type === StickerType.APNG) { this.sendAnimatedSticker(link, sticker.id, channelId); return { cancel: true }; From 2cf52d0775106dc46d09dc145c8bb30ea9cd05d7 Mon Sep 17 00:00:00 2001 From: zImPatrick <23613354+zImPatrick@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:41:50 +0100 Subject: [PATCH 11/23] AlwaysAnimate: Add guild banner (#2036) --- src/plugins/alwaysAnimate/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/alwaysAnimate/index.ts b/src/plugins/alwaysAnimate/index.ts index d53e51452..eae5a5d3d 100644 --- a/src/plugins/alwaysAnimate/index.ts +++ b/src/plugins/alwaysAnimate/index.ts @@ -46,6 +46,13 @@ export default definePlugin({ match: /(?<=\.activityEmoji,.+?animate:)\i/, replace: "!0" } + }, + { + find: ".animatedBannerHoverLayer,onMouseEnter:", + replacement: { + match: /(?<=guildBanner:\i,animate:)\i/, + replace: "!0" + } } ] }); From b32959126e506c886d45fad2abb48a66d0554e4c Mon Sep 17 00:00:00 2001 From: Andrew Grant Date: Wed, 13 Dec 2023 17:54:09 -0500 Subject: [PATCH 12/23] TypingIndicator: setting to disable for current channel (#2043) --- src/plugins/typingIndicator/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index c5cf5a9d0..171c560d8 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -21,7 +21,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findExportedComponentLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; +import { ChannelStore, GuildMemberStore, i18n, RelationshipStore, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; import { buildSeveralUsers } from "../typingTweaks"; @@ -47,7 +47,7 @@ function TypingIndicator({ channelId }: { channelId: string; }) { return oldKeys.length === currentKeys.length && currentKeys.every(key => old[key] != null); } ); - + const currentChannelId: string = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId()); const guildId = ChannelStore.getChannel(channelId).guild_id; if (!settings.store.includeMutedChannels) { @@ -55,6 +55,10 @@ function TypingIndicator({ channelId }: { channelId: string; }) { if (isChannelMuted) return null; } + if (!settings.store.includeCurrentChannel) { + if (currentChannelId === channelId) return null; + } + const myId = UserStore.getCurrentUser()?.id; const typingUsersArray = Object.keys(typingUsers).filter(id => id !== myId && !(RelationshipStore.isBlocked(id) && !settings.store.includeBlockedUsers)); @@ -101,6 +105,11 @@ function TypingIndicator({ channelId }: { channelId: string; }) { } const settings = definePluginSettings({ + includeCurrentChannel: { + type: OptionType.BOOLEAN, + description: "Whether to show the typing indicator for the currently selected channel", + default: true + }, includeMutedChannels: { type: OptionType.BOOLEAN, description: "Whether to show the typing indicator for muted channels.", From a8b0ce6f0353f5c6642c26afe8e0e8e371a5766a Mon Sep 17 00:00:00 2001 From: V Date: Thu, 14 Dec 2023 01:29:57 +0100 Subject: [PATCH 13/23] fix(notrack): murder sentry --- src/webpack/patchWebpack.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index f131471bf..db47c875a 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -58,6 +58,9 @@ if (window[WEBPACK_CHUNK]) { // normally, this is populated via webpackGlobal.push, which we patch below. // However, Discord has their .m prepopulated. // Thus, we use this hack to immediately access their wreq.m and patch all already existing factories + // + // Update: Discord now has TWO webpack instances. Their normal one and sentry + // Sentry does not push chunks to the global at all, so this same patch now also handles their sentry modules Object.defineProperty(Function.prototype, "m", { set(v: any) { // When using react devtools or other extensions, we may also catch their webpack here. @@ -65,8 +68,6 @@ if (window[WEBPACK_CHUNK]) { if (new Error().stack?.includes("discord.com")) { logger.info("Found webpack module factory"); patchFactories(v); - - delete (Function.prototype as any).m; } Object.defineProperty(this, "m", { @@ -142,7 +143,7 @@ function patchFactories(factories: Record Date: Wed, 13 Dec 2023 21:41:09 -0300 Subject: [PATCH 14/23] Fix reporter and AlwaysAnimate patch --- scripts/generateReport.ts | 8 ++++++-- src/plugins/alwaysAnimate/index.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 54db96e66..a91e81877 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -211,9 +211,12 @@ page.on("console", async e => { switch (tag) { case "WebpackInterceptor:": + const patchFailMatch = message.match(/Patch by (.+?) (had no effect|errored|found no module) \(Module id is (.+?)\): (.+)/)!; + if (!patchFailMatch) break; + process.exitCode = 1; - const [, plugin, type, id, regex] = message.match(/Patch by (.+?) (had no effect|errored|found no module) \(Module id is (.+?)\): (.+)/)!; + const [, plugin, type, id, regex] = patchFailMatch; report.badPatches.push({ plugin, type, @@ -253,7 +256,7 @@ page.on("console", async e => { ).then(a => a.join(" ").trim()); - if (text.length && !text.startsWith("Failed to load resource: the server responded with a status of") && !text.includes("found no module Filter:")) { + if (text.length && !text.startsWith("Failed to load resource: the server responded with a status of") && !text.includes("Webpack")) { console.error("[Unexpected Error]", text); report.otherErrors.push(text); } @@ -293,6 +296,7 @@ function runTime(token: string) { p.patches?.forEach(patch => { patch.plugin = p.name; delete patch.predicate; + delete patch.group; if (!Array.isArray(patch.replacement)) patch.replacement = [patch.replacement]; diff --git a/src/plugins/alwaysAnimate/index.ts b/src/plugins/alwaysAnimate/index.ts index eae5a5d3d..dbec3b4e3 100644 --- a/src/plugins/alwaysAnimate/index.ts +++ b/src/plugins/alwaysAnimate/index.ts @@ -48,9 +48,10 @@ export default definePlugin({ } }, { + // Guild Banner find: ".animatedBannerHoverLayer,onMouseEnter:", replacement: { - match: /(?<=guildBanner:\i,animate:)\i/, + match: /(?<=guildBanner:\i,animate:)\i(?=}\))/, replace: "!0" } } From 2f1dc2c704d3ee284719576bbd9153266e41087c Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:46:51 -0300 Subject: [PATCH 15/23] reporter: fix icon --- scripts/generateReport.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index a91e81877..b4033ecb3 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -137,7 +137,7 @@ async function printReport() { body: JSON.stringify({ description: "Here's the latest Vencord Report!", username: "Vencord Reporter" + (CANARY ? " (Canary)" : ""), - avatar_url: "https://cdn.discordapp.com/icons/1015060230222131221/6101cff21e241cebb60c4a01563d0c01.webp?size=512", + avatar_url: "https://cdn.discordapp.com/avatars/1017176847865352332/c312b6b44179ae6817de7e4b09e9c6af.webp?size=512", embeds: [ { title: "Bad Patches", From 2cd82944e360a5b045b5c28a3fac139eb9a00598 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:01:07 -0300 Subject: [PATCH 16/23] Move commons from discord utils; Make ThemesTab use invite modal util --- src/api/Commands/commandHelpers.ts | 3 +-- src/components/VencordSettings/ThemesTab.tsx | 13 +++---------- src/plugins/greetStickerPicker/index.tsx | 3 +-- src/plugins/spotifyShareCommands/index.ts | 3 +-- src/plugins/voiceMessages/index.tsx | 3 +-- src/utils/discord.tsx | 9 +-------- src/webpack/common/utils.ts | 4 ++++ 7 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/api/Commands/commandHelpers.ts b/src/api/Commands/commandHelpers.ts index 8f4a88e4b..dc5ecfd67 100644 --- a/src/api/Commands/commandHelpers.ts +++ b/src/api/Commands/commandHelpers.ts @@ -16,10 +16,9 @@ * along with this program. If not, see . */ -import { MessageActions } from "@utils/discord"; import { mergeDefaults } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; -import { SnowflakeUtils } from "@webpack/common"; +import { MessageActions, SnowflakeUtils } from "@webpack/common"; import { Message } from "discord-types/general"; import type { PartialDeep } from "type-fest"; diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index e65de2192..2808494a1 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -21,12 +21,13 @@ import { classNameFactory } from "@api/Styles"; import { Flex } from "@components/Flex"; import { DeleteIcon } from "@components/Icons"; import { Link } from "@components/Link"; +import { openInviteModal } from "@utils/discord"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { showItemInFolder } from "@utils/native"; import { useAwaiter } from "@utils/react"; import { findByPropsLazy, findLazy } from "@webpack"; -import { Button, Card, FluxDispatcher, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common"; +import { Button, Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common"; import { UserThemeHeader } from "main/themes"; import type { ComponentType, Ref, SyntheticEvent } from "react"; @@ -125,15 +126,7 @@ function ThemeCard({ theme, enabled, onChange, onDelete }: ThemeCardProps) { href={`https://discord.gg/${theme.invite}`} onClick={async e => { e.preventDefault(); - const { invite } = await InviteActions.resolveInvite(theme.invite, "Desktop Modal"); - if (!invite) return showToast("Invalid or expired invite"); - - FluxDispatcher.dispatch({ - type: "INVITE_MODAL_OPEN", - invite, - code: theme.invite, - context: "APP" - }); + theme.invite != null && openInviteModal(theme.invite).catch(() => showToast("Invalid or expired invite")); }} > Discord Server diff --git a/src/plugins/greetStickerPicker/index.tsx b/src/plugins/greetStickerPicker/index.tsx index c2104af4e..73bb5125e 100644 --- a/src/plugins/greetStickerPicker/index.tsx +++ b/src/plugins/greetStickerPicker/index.tsx @@ -18,10 +18,9 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import { MessageActions } from "@utils/discord"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { ContextMenuApi, FluxDispatcher, Menu } from "@webpack/common"; +import { ContextMenuApi, FluxDispatcher, Menu, MessageActions } from "@webpack/common"; import { Channel, Message } from "discord-types/general"; interface Sticker { diff --git a/src/plugins/spotifyShareCommands/index.ts b/src/plugins/spotifyShareCommands/index.ts index 3569dd288..a3b82dc20 100644 --- a/src/plugins/spotifyShareCommands/index.ts +++ b/src/plugins/spotifyShareCommands/index.ts @@ -18,10 +18,9 @@ import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands"; import { Devs } from "@utils/constants"; -import { MessageActions } from "@utils/discord"; import definePlugin from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { FluxDispatcher } from "@webpack/common"; +import { FluxDispatcher, MessageActions } from "@webpack/common"; interface Album { id: string; diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx index 17e10a4b8..f4898de68 100644 --- a/src/plugins/voiceMessages/index.tsx +++ b/src/plugins/voiceMessages/index.tsx @@ -21,13 +21,12 @@ import "./styles.css"; import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; import { Microphone } from "@components/Icons"; import { Devs } from "@utils/constants"; -import { MessageActions } from "@utils/discord"; import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; import { useAwaiter } from "@utils/react"; import definePlugin from "@utils/types"; import { chooseFile } from "@utils/web"; import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { Button, FluxDispatcher, Forms, lodash, Menu, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; +import { Button, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common"; import { ComponentType } from "react"; import { VoiceRecorderDesktop } from "./DesktopRecorder"; diff --git a/src/utils/discord.tsx b/src/utils/discord.tsx index 788f0add7..74e1aefe8 100644 --- a/src/utils/discord.tsx +++ b/src/utils/discord.tsx @@ -17,18 +17,11 @@ */ import { MessageObject } from "@api/MessageEvents"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, MaskedLink, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common"; +import { ChannelStore, ComponentDispatch, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common"; import { Guild, Message, User } from "discord-types/general"; import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal"; -export const MessageActions = findByPropsLazy("editMessage", "sendMessage"); -export const UserProfileActions = findByPropsLazy("openUserProfileModal", "closeUserProfileModal"); -export const InviteActions = findByPropsLazy("resolveInvite"); - -const InviteModalStore = findStoreLazy("InviteModalStore"); - /** * Open the invite modal * @param code The invite code diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index f5d2a9666..c62f745a9 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -133,3 +133,7 @@ export const zustandCreate: typeof import("zustand").default = findByCodeLazy("w const persistFilter = filters.byCode("[zustand persist middleware]"); export const { persist: zustandPersist }: typeof import("zustand/middleware") = findLazy(m => m.persist && persistFilter(m.persist)); + +export const MessageActions = findByPropsLazy("editMessage", "sendMessage"); +export const UserProfileActions = findByPropsLazy("openUserProfileModal", "closeUserProfileModal"); +export const InviteActions = findByPropsLazy("resolveInvite"); From 467c5e0c4c00b021ec8ae8ecf0ee929630ec7f31 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:40:59 -0300 Subject: [PATCH 17/23] Delete FixImagesQuality Discord fixed their issue with images getting converted to webp losing quality. In the future this plugin can be re-purposed to keep images format as the original, but that requires more than just removing part of the Discord code, and a bit of study to make sure it does not cause issues. --- src/plugins/fixImagesQuality/index.ts | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 src/plugins/fixImagesQuality/index.ts diff --git a/src/plugins/fixImagesQuality/index.ts b/src/plugins/fixImagesQuality/index.ts deleted file mode 100644 index 4acd9a921..000000000 --- a/src/plugins/fixImagesQuality/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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: "FixImagesQuality", - description: "Fixes the quality of images in the chat being horrible.", - authors: [Devs.Nuckyz], - patches: [ - { - find: "handleImageLoad=", - replacement: [ - { - match: /(?<=getSrc\(\i\){.+?return )\i\.SUPPORTS_WEBP.+?:(?=\i&&\(\i="png"\))/, - replace: "" - } - ] - } - ] -}); From 9950bf00b276b69819cdb41d570877662c66e511 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 17 Dec 2023 18:06:16 -0300 Subject: [PATCH 18/23] GameActivityToggle: option to use old icon --- src/plugins/gameActivityToggle/index.tsx | 47 +++++++++++++++++------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/plugins/gameActivityToggle/index.tsx b/src/plugins/gameActivityToggle/index.tsx index 99cee5b1c..51feb9165 100644 --- a/src/plugins/gameActivityToggle/index.tsx +++ b/src/plugins/gameActivityToggle/index.tsx @@ -16,10 +16,11 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/Settings"; import { disableStyle, enableStyle } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; import { StatusSettingsStores } from "@webpack/common"; @@ -28,22 +29,31 @@ import style from "./style.css?managed"; const Button = findComponentByCodeLazy("Button.Sizes.NONE,disabled:"); function makeIcon(showCurrentGame?: boolean) { - const controllerIcon = "M3.06 20.4q-1.53 0-2.37-1.065T.06 16.74l1.26-9q.27-1.8 1.605-2.97T6.06 3.6h11.88q1.8 0 3.135 1.17t1.605 2.97l1.26 9q.21 1.53-.63 2.595T20.94 20.4q-.63 0-1.17-.225T18.78 19.5l-2.7-2.7H7.92l-2.7 2.7q-.45.45-.99.675t-1.17.225Zm14.94-7.2q.51 0 .855-.345T19.2 12q0-.51-.345-.855T18 10.8q-.51 0-.855.345T16.8 12q0 .51.345 .855T18 13.2Zm-2.4-3.6q.51 0 .855-.345T16.8 8.4q0-.51-.345-.855T15.6 7.2q-.51 0-.855.345T14.4 8.4q0 .51.345 .855T15.6 9.6ZM6.9 13.2h1.8v-2.1h2.1v-1.8h-2.1v-2.1h-1.8v2.1h-2.1v1.8h2.1v2.1Z"; + const { oldIcon } = settings.use(["oldIcon"]); + + const redLinePath = !oldIcon + ? "M22.7 2.7a1 1 0 0 0-1.4-1.4l-20 20a1 1 0 1 0 1.4 1.4Z" + : "M23 2.27 21.73 1 1 21.73 2.27 23 23 2.27Z"; + + const maskBlackPath = !oldIcon + ? "M23.27 4.73 19.27 .73 -.27 20.27 3.73 24.27Z" + : "M23.27 4.54 19.46.73 .73 19.46 4.54 23.27 23.27 4.54Z"; + return function () { return ( - {showCurrentGame ? ( - - ) : ( - <> - - - - - - - - )} + + {!showCurrentGame && <> + + + + + + } ); }; @@ -63,10 +73,19 @@ function GameActivityToggleButton() { ); } +const settings = definePluginSettings({ + oldIcon: { + type: OptionType.BOOLEAN, + description: "Use the old icon style before Discord icon redesign", + default: false + } +}); + export default definePlugin({ name: "GameActivityToggle", description: "Adds a button next to the mic and deafen button to toggle game activity.", authors: [Devs.Nuckyz, Devs.RuukuLada], + settings, patches: [ { From 2e04b3d1ef34a21fb2c897bef8e4ea908c2de9c4 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sun, 17 Dec 2023 21:12:42 +0000 Subject: [PATCH 19/23] Implement Twitter easter egg for ShowConnections (#2062) --- src/plugins/showConnections/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index d4d59465e..83600e867 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -33,6 +33,7 @@ import { VerifiedIcon } from "./VerifiedIcon"; const Section = findComponentByCodeLazy(".lastSection", "children:"); const ThemeStore = findStoreLazy("ThemeStore"); +const platformHooks: { useLegacyPlatformType(platform: string): string; } = findByPropsLazy("useLegacyPlatformType"); const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"'); @@ -111,7 +112,7 @@ function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) { } function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { - const platform = platforms.get(connection.type); + const platform = platforms.get(platformHooks.useLegacyPlatformType(connection.type)); const url = platform.getPlatformUserUrl?.(connection); const img = ( From fdf3480b278536bb85759345279715575480dce0 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 20 Dec 2023 01:33:40 -0300 Subject: [PATCH 20/23] Fix DeArrow patch --- src/plugins/dearrow/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/dearrow/index.tsx b/src/plugins/dearrow/index.tsx index 80eb84aa7..b02c80d3d 100644 --- a/src/plugins/dearrow/index.tsx +++ b/src/plugins/dearrow/index.tsx @@ -147,7 +147,7 @@ export default definePlugin({ replacement: [ // patch componentDidMount to replace embed thumbnail and title { - match: /render\(\)\{let\{embed:/, + match: /render\(\)\{.{0,30}let\{embed:/, replace: "componentDidMount=$self.embedDidMount;$&" }, From 686f2d925f5d3f238b813481f827b7cd9ce2e0eb Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 21 Dec 2023 23:41:12 +0100 Subject: [PATCH 21/23] fix canary crashing --- src/plugins/blurNsfw/index.ts | 4 ++-- src/plugins/messageLogger/index.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/blurNsfw/index.ts b/src/plugins/blurNsfw/index.ts index cb6be54c9..a80f9f260 100644 --- a/src/plugins/blurNsfw/index.ts +++ b/src/plugins/blurNsfw/index.ts @@ -45,8 +45,8 @@ export default definePlugin({ { find: ".embedWrapper,embed", replacement: [{ - match: /\.embedWrapper/g, - replace: "$&+(this.props.channel.nsfw?' vc-nsfw-img':'')" + match: /\.embedWrapper(?=.+?channel_id:(\i)\.id)/g, + replace: "$&+($1.nsfw?' vc-nsfw-img':'')" }] } ], diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index ac43a9f0c..ef0aa03bb 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -328,6 +328,7 @@ export default definePlugin({ // Attachment renderer // Module 96063 find: ".removeAttachmentHoverButton", + group: true, replacement: [ { match: /(className:\i,attachment:\i),/, From 109d842e29476b140293ac4c3103a3ffa4dd3953 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:46:22 -0300 Subject: [PATCH 22/23] Fix NSFWGateBypass possibly Vencord --- src/plugins/nsfwGateBypass/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/nsfwGateBypass/index.ts b/src/plugins/nsfwGateBypass/index.ts index 3c5dbb4ca..b6f0f3e86 100644 --- a/src/plugins/nsfwGateBypass/index.ts +++ b/src/plugins/nsfwGateBypass/index.ts @@ -27,8 +27,8 @@ export default definePlugin({ { find: ".nsfwAllowed=null", replacement: { - match: /(\w+)\.nsfwAllowed=/, - replace: "$1.nsfwAllowed=true;", + match: /(?<=\.nsfwAllowed=)null!==.+?(?=[,;])/, + replace: "!0", }, }, ], From 5dee2e8549de195f7bdb213ce7bb7f6dde840811 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:46:34 -0300 Subject: [PATCH 23/23] Future proof reporter to work in latest canary --- scripts/generateReport.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index b4033ecb3..0a17e8d7e 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -350,7 +350,7 @@ function runTime(token: string) { let invalidEntryPoint = false; for (const id of chunkIds) { - if (!wreq.u(id)) continue; + if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; const isWasm = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) @@ -376,9 +376,22 @@ function runTime(token: string) { } catch (err) { } } - const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record | null; - if (!allChunks) throw new Error("Failed to get all chunks"); - const chunksLeft = Object.keys(allChunks).filter(id => { + // Matches "id" or id: + const chunkIdRegex = /(?:"(\d+?)")|(?:(\d+?):)/g; + const wreqU = wreq.u.toString(); + + const allChunks = [] as string[]; + let currentMatch: RegExpExecArray | null; + + while ((currentMatch = chunkIdRegex.exec(wreqU)) != null) { + const id = currentMatch[1] ?? currentMatch[2]; + if (id == null) continue; + + allChunks.push(id); + } + + if (allChunks.length === 0) throw new Error("Failed to get all chunks"); + const chunksLeft = allChunks.filter(id => { return !(validChunks.has(id) || invalidChunks.has(id)); });