From 8711dd9a4b26077faf17cccd14564ebc04132cd4 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:51:41 -0300 Subject: [PATCH 01/13] WebContextMenus: Fix input bar menu --- src/plugins/webContextMenus.web/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index a11ef243..66123805 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -164,8 +164,8 @@ export default definePlugin({ find: 'getElementById("slate-toolbar"', predicate: () => settings.store.addBack, replacement: { - match: /(?<=handleContextMenu\(\i\)\{.{0,200}isPlatformEmbedded)\?/, - replace: "||true?" + match: /(?<=handleContextMenu\(\i\)\{.{0,200}isPlatformEmbedded)\)/, + replace: "||true)" } }, { From cdfc89b8192144bc7b58225655c1d52562a84e28 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:39:36 -0300 Subject: [PATCH 02/13] NoScreensharePreview: Migrate to stock Discord feature --- src/plugins/noScreensharePreview/index.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/noScreensharePreview/index.ts b/src/plugins/noScreensharePreview/index.ts index ca50ad28..6ad39a90 100644 --- a/src/plugins/noScreensharePreview/index.ts +++ b/src/plugins/noScreensharePreview/index.ts @@ -16,20 +16,23 @@ * along with this program. If not, see . */ +import { Settings } from "@api/Settings"; +import { getUserSettingLazy } from "@api/UserSettings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; +const DisableStreamPreviews = getUserSettingLazy("voiceAndVideo", "disableStreamPreviews")!; + +// @TODO: Delete this plugin in the future export default definePlugin({ name: "NoScreensharePreview", description: "Disables screenshare previews from being sent.", authors: [Devs.Nuckyz], - patches: [ - { - find: '"ApplicationStreamPreviewUploadManager"', - replacement: { - match: /await \i\.\i\.(makeChunkedRequest\(|post\(\{url:)\i\.\i\.STREAM_PREVIEW.+?\}\)/g, - replace: "0" - } + start() { + if (!DisableStreamPreviews.getSetting()) { + DisableStreamPreviews.updateSetting(true); } - ] + + Settings.plugins.NoScreensharePreview.enabled = false; + } }); From df44edd41ba185ab2afb437cda16c4bafd87ac7e Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:07:30 -0500 Subject: [PATCH 03/13] BetterFolders: Fix including open folders in main sidebar (#3064) --- src/plugins/betterFolders/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 68746d36..6f9b796e 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -159,7 +159,7 @@ export default definePlugin({ ] }, { - find: ".FOLDER_ITEM_GUILD_ICON_MARGIN);", + find: ".expandedFolderBackground,", predicate: () => settings.store.sidebar, replacement: [ // We use arguments[0] to access the isBetterFolders variable in this nested folder component (the parent exports all the props so we don't have to patch it) From a3f5dc39a09506ecbeaa3c496ba9a1a95189a2cc Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 7 Dec 2024 00:13:59 +0100 Subject: [PATCH 04/13] CallTimer: fix crashing on canary --- src/plugins/callTimer/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/callTimer/index.tsx b/src/plugins/callTimer/index.tsx index c018cc71..01b1cb98 100644 --- a/src/plugins/callTimer/index.tsx +++ b/src/plugins/callTimer/index.tsx @@ -75,10 +75,11 @@ export default definePlugin({ patches: [{ find: "renderConnectionStatus(){", replacement: { - match: /(?<=renderConnectionStatus\(\)\{.+\.channel,children:)\i/, + match: /(?<=renderConnectionStatus\(\)\{.+\.channel,children:)\i(?=\})/, replace: "[$&, $self.renderTimer(this.props.channel.id)]" } }], + renderTimer(channelId: string) { return From cea0a3c9d97bbec08241a7294c2d0c7d41225d72 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:14:49 -0300 Subject: [PATCH 05/13] NoScreensharePreview: Allow plugin to be turned on/off --- src/plugins/noScreensharePreview/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/noScreensharePreview/index.ts b/src/plugins/noScreensharePreview/index.ts index 6ad39a90..d4bb9c1e 100644 --- a/src/plugins/noScreensharePreview/index.ts +++ b/src/plugins/noScreensharePreview/index.ts @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -import { Settings } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; @@ -28,11 +27,16 @@ export default definePlugin({ name: "NoScreensharePreview", description: "Disables screenshare previews from being sent.", authors: [Devs.Nuckyz], + start() { if (!DisableStreamPreviews.getSetting()) { DisableStreamPreviews.updateSetting(true); } + }, - Settings.plugins.NoScreensharePreview.enabled = false; + stop() { + if (DisableStreamPreviews.getSetting()) { + DisableStreamPreviews.updateSetting(false); + } } }); From 3a339636d138da5745322f6e317331d7d9387dc2 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:55:37 -0300 Subject: [PATCH 06/13] Remove old plugin migrations --- src/plugins/disableCallIdle/index.ts | 2 -- src/plugins/newGuildSettings/index.tsx | 4 +--- src/plugins/partyMode/index.ts | 3 +-- src/plugins/serverInfo/index.tsx | 2 -- src/plugins/showHiddenThings/index.ts | 3 +-- src/plugins/youtubeAdblock.desktop/index.ts | 2 -- 6 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/plugins/disableCallIdle/index.ts b/src/plugins/disableCallIdle/index.ts index 82ab56f2..5a1ac84f 100644 --- a/src/plugins/disableCallIdle/index.ts +++ b/src/plugins/disableCallIdle/index.ts @@ -16,11 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("DisableCallIdle", "DisableDMCallIdle"); export default definePlugin({ name: "DisableCallIdle", description: "Disables automatically getting kicked from a DM voice call after 3 minutes and being moved to an AFK voice channel.", diff --git a/src/plugins/newGuildSettings/index.tsx b/src/plugins/newGuildSettings/index.tsx index 7cfb073f..e613f7a0 100644 --- a/src/plugins/newGuildSettings/index.tsx +++ b/src/plugins/newGuildSettings/index.tsx @@ -20,7 +20,7 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; -import { definePluginSettings, migratePluginSettings } from "@api/Settings"; +import { definePluginSettings } from "@api/Settings"; import { CogWheel } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -115,8 +115,6 @@ function applyDefaultSettings(guildId: string | null) { } } - -migratePluginSettings("NewGuildSettings", "MuteNewGuild"); export default definePlugin({ name: "NewGuildSettings", description: "Automatically mute new servers and change various other settings upon joining", diff --git a/src/plugins/partyMode/index.ts b/src/plugins/partyMode/index.ts index c40f2e3c..f7cddbf9 100644 --- a/src/plugins/partyMode/index.ts +++ b/src/plugins/partyMode/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings, migratePluginSettings } from "@api/Settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType, ReporterTestable } from "@utils/types"; import { FluxDispatcher } from "@webpack/common"; @@ -41,7 +41,6 @@ const settings = definePluginSettings({ }, }); -migratePluginSettings("PartyMode", "Party mode 🎉"); export default definePlugin({ name: "PartyMode", description: "Allows you to use party mode cause the party never ends ✨", diff --git a/src/plugins/serverInfo/index.tsx b/src/plugins/serverInfo/index.tsx index a6dd6edf..2a3f3adf 100644 --- a/src/plugins/serverInfo/index.tsx +++ b/src/plugins/serverInfo/index.tsx @@ -5,7 +5,6 @@ */ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; -import { migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Menu } from "@webpack/common"; @@ -25,7 +24,6 @@ const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild; ); }; -migratePluginSettings("ServerInfo", "ServerProfile"); // what was I thinking with this name lmao export default definePlugin({ name: "ServerInfo", description: "Allows you to view info about a server", diff --git a/src/plugins/showHiddenThings/index.ts b/src/plugins/showHiddenThings/index.ts index 30edb247..a5cf8129 100644 --- a/src/plugins/showHiddenThings/index.ts +++ b/src/plugins/showHiddenThings/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings, migratePluginSettings } from "@api/Settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType, PluginSettingDef } from "@utils/types"; @@ -35,7 +35,6 @@ const settings = definePluginSettings({ disableDisallowedDiscoveryFilters: opt("Disable filters in Server Discovery search that hide NSFW & disallowed servers."), }); -migratePluginSettings("ShowHiddenThings", "ShowTimeouts"); export default definePlugin({ name: "ShowHiddenThings", tags: ["ShowTimeouts", "ShowInvitesPaused", "ShowModView", "DisableDiscoveryFilters"], diff --git a/src/plugins/youtubeAdblock.desktop/index.ts b/src/plugins/youtubeAdblock.desktop/index.ts index 708b908d..48f91179 100644 --- a/src/plugins/youtubeAdblock.desktop/index.ts +++ b/src/plugins/youtubeAdblock.desktop/index.ts @@ -4,12 +4,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; // The entire code of this plugin can be found in native.ts -migratePluginSettings("YoutubeAdblock", "WatchTogetherAdblock"); export default definePlugin({ name: "YoutubeAdblock", description: "Block ads in YouTube embeds and the WatchTogether activity via AdGuard", From 99dc65fe4e9c50d6eef2f62c4211e80bf0a20477 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 7 Dec 2024 20:31:08 -0300 Subject: [PATCH 07/13] Fix TypingIndicator & CallTimer --- src/plugins/callTimer/index.tsx | 2 +- src/plugins/showHiddenChannels/index.tsx | 2 +- src/plugins/typingIndicator/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/callTimer/index.tsx b/src/plugins/callTimer/index.tsx index 01b1cb98..e16abc4a 100644 --- a/src/plugins/callTimer/index.tsx +++ b/src/plugins/callTimer/index.tsx @@ -75,7 +75,7 @@ export default definePlugin({ patches: [{ find: "renderConnectionStatus(){", replacement: { - match: /(?<=renderConnectionStatus\(\)\{.+\.channel,children:)\i(?=\})/, + match: /(?<=renderConnectionStatus\(\){.+\.channel,children:).+?}\):\i(?=}\))/, replace: "[$&, $self.renderTimer(this.props.channel.id)]" } }], diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 6b67aee8..181a6bc9 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -168,7 +168,7 @@ export default definePlugin({ }, // Add the hidden eye icon if the channel is hidden { - match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/, + match: /\.name,{.{0,140}\.children.+?:null(?<=,channel:(\i).+?)/, replace: (m, channel) => `${m},$self.isHiddenChannel(${channel})?$self.HiddenChannelIcon():null` }, // Make voice channels also appear as muted if they are muted diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index e9e34331..e6a1b3b4 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -163,7 +163,7 @@ export default definePlugin({ { find: "UNREAD_IMPORTANT:", replacement: { - match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/, + match: /\.name,{.{0,140}\.children.+?:null(?<=,channel:(\i).+?)/, replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())" } }, From 4a5f0838e217253174401bb5e523c234239fd748 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 7 Dec 2024 20:32:16 -0300 Subject: [PATCH 08/13] Remove workaround for Devtools theme --- src/main/patcher.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/patcher.ts b/src/main/patcher.ts index e858f3fc..e5b87290 100644 --- a/src/main/patcher.ts +++ b/src/main/patcher.ts @@ -17,7 +17,7 @@ */ import { onceDefined } from "@shared/onceDefined"; -import electron, { app, BrowserWindowConstructorOptions, Menu, nativeTheme } from "electron"; +import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron"; import { dirname, join } from "path"; import { initIpc } from "./ipcMain"; @@ -100,19 +100,6 @@ if (!IS_VANILLA) { super(options); initIpc(this); - - // Workaround for https://github.com/electron/electron/issues/43367. Vesktop also has its own workaround - // @TODO: Remove this when the issue is fixed - if (IS_DISCORD_DESKTOP) { - this.webContents.on("devtools-opened", () => { - if (!nativeTheme.shouldUseDarkColors) return; - - nativeTheme.themeSource = "light"; - setTimeout(() => { - nativeTheme.themeSource = "dark"; - }, 100); - }); - } } else super(options); } } From 8d65bcf74319004b8dbafb2599a109879ace1b52 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:09:54 -0300 Subject: [PATCH 09/13] BetterFolders: Fix folder icon setting --- src/plugins/betterFolders/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 6f9b796e..c43e1711 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -185,7 +185,7 @@ export default definePlugin({ { // Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always, - match: /(?<=\.wrapper,children:\[)/, + match: /(?<=\.isExpanded\),children:\[)/, replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&" }, { From 9d3c91e9df7f5168da2ce8b6d1f60e0fd792f935 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:29:15 -0300 Subject: [PATCH 10/13] TypingTweaks: Fix plugin --- src/plugins/typingTweaks/index.tsx | 45 ++++++++++++++---------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/plugins/typingTweaks/index.tsx b/src/plugins/typingTweaks/index.tsx index e2bbb4bc..026cd527 100644 --- a/src/plugins/typingTweaks/index.tsx +++ b/src/plugins/typingTweaks/index.tsx @@ -91,34 +91,31 @@ export default definePlugin({ name: "TypingTweaks", description: "Show avatars and role colours in the typing indicator", authors: [Devs.zt], + settings, + patches: [ - // Style the indicator and add function call to modify the children before rendering { - find: "getCooldownTextStyle", - replacement: { - match: /(?<=children:\[(\i)\.length>0.{0,200}?"aria-atomic":!0,children:)\i/, - replace: "$self.mutateChildren(this.props, $1, $&), style: $self.TYPING_TEXT_STYLE" - } - }, - // Changes the indicator to keep the user object when creating the list of typing users - { - find: "getCooldownTextStyle", - replacement: { - match: /(?<=map\(\i=>)\i\.\i\.getName\(\i,this\.props\.channel\.id,(\i)\)/, - replace: "$1" - } - }, - // Adds the alternative formatting for several users typing - { - find: "getCooldownTextStyle", - replacement: { - match: /(,{a:(\i),b:(\i),c:\i}\):)\i\.\i\.string\(\i\.\i#{intl::SEVERAL_USERS_TYPING}\)(?<=(\i)\.length.+?)/, - replace: (_, rest, a, b, users) => `${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2 })` - }, - predicate: () => settings.store.alternativeFormatting + find: "#{intl::THREE_USERS_TYPING}", + replacement: [ + { + // Style the indicator and add function call to modify the children before rendering + match: /(?<=children:\[(\i)\.length>0.{0,200}?"aria-atomic":!0,children:)\i(?<=guildId:(\i).+?)/, + replace: "$self.mutateChildren($2,$1,$&),style:$self.TYPING_TEXT_STYLE" + }, + { + // Changes the indicator to keep the user object when creating the list of typing users + match: /\.map\((\i)=>\i\.\i\.getName\(\i,\i\.id,\1\)\)/, + replace: "" + }, + { + // Adds the alternative formatting for several users typing + match: /(,{a:(\i),b:(\i),c:\i}\):\i\.length>3&&\(\i=)\i\.\i\.string\(\i\.\i#{intl::SEVERAL_USERS_TYPING}\)(?<=(\i)\.length.+?)/, + replace: (_, rest, a, b, users) => `${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2 })`, + predicate: () => settings.store.alternativeFormatting + } + ] } ], - settings, TYPING_TEXT_STYLE: { display: "grid", From dcfddcbc2150c07f2dab5b6c43d9919eec005352 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:37:21 -0500 Subject: [PATCH 11/13] ConsoleJanitor: Add HLJS deprecations (#3062) --- src/plugins/consoleJanitor/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index 2c29bf67..03c30ede 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -66,6 +66,13 @@ export default definePlugin({ }, patches: [ + { + find: "https://github.com/highlightjs/highlight.js/issues/2277", + replacement: { + match: /(?<=&&\()console.log\(`Deprecated.+?`\),/, + replace: "" + } + }, { find: 'react-spring: The "interpolate" function', replacement: { From 464c4a9b614a93443575acfd160388d3eb09cb2f Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Tue, 10 Dec 2024 23:06:34 -0500 Subject: [PATCH 12/13] TypingTweaks: Fix usernames not being colored (#3070) --- src/plugins/typingTweaks/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/typingTweaks/index.tsx b/src/plugins/typingTweaks/index.tsx index 026cd527..9e6459ab 100644 --- a/src/plugins/typingTweaks/index.tsx +++ b/src/plugins/typingTweaks/index.tsx @@ -125,7 +125,7 @@ export default definePlugin({ buildSeveralUsers, - mutateChildren(props: any, users: User[], children: any) { + mutateChildren(guildId: any, users: User[], children: any) { try { if (!Array.isArray(children)) { return children; @@ -135,7 +135,7 @@ export default definePlugin({ return children.map(c => c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c)) - ? + ? : c ); } catch (e) { From 2dc8c2bf764be5409460bf96e16ea0c273cd0bf7 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Thu, 12 Dec 2024 01:47:55 -0500 Subject: [PATCH 13/13] Fix multiple plugins for latest Discord update (#3072) --- src/plugins/consoleJanitor/index.ts | 6 ++-- src/plugins/fakeNitro/index.tsx | 8 ++--- src/plugins/favEmojiFirst/index.ts | 2 +- src/plugins/messageLogger/index.tsx | 44 +++++++++++++------------- src/plugins/moreUserTags/index.tsx | 8 ++--- src/plugins/noBlockedMessages/index.ts | 4 +-- src/plugins/noPendingCount/index.ts | 4 +-- src/plugins/volumeBooster/index.ts | 4 +-- src/plugins/whoReacted/index.tsx | 4 +-- 9 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index 03c30ede..d251ff74 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -74,9 +74,9 @@ export default definePlugin({ } }, { - find: 'react-spring: The "interpolate" function', + find: 'The "interpolate" function is deprecated in v10 (use "to" instead)', replacement: { - match: /,console.warn\('react-spring: The "interpolate" function is deprecated in v10 \(use "to" instead\)'\)/, + match: /,console.warn\(\i\+'The "interpolate" function is deprecated in v10 \(use "to" instead\)'\)/, replace: "" } }, @@ -133,7 +133,7 @@ export default definePlugin({ { find: "Slow dispatch on", replacement: { - match: /\i\.totalTime>100&&\i\.verbose\("Slow dispatch on ".+?\)\);/, + match: /\i\.totalTime>\i&&\i\.verbose\("Slow dispatch on ".+?\)\);/, replace: "" } }, diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 86c5ae4d..d1aa69c7 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -207,8 +207,8 @@ function makeBypassPatches(): Omit { return { find: "canUseCustomStickersEverywhere:", replacement: mapping.map(({ func, predicate }) => ({ - match: new RegExp(String.raw`(?<=${func}:function\(\i(?:,\i)?\){)`), - replace: "return true;", + match: new RegExp(String.raw`(?<=${func}:)\i`), + replace: "() => true", predicate })) }; @@ -297,8 +297,8 @@ export default definePlugin({ replacement: [ { // Overwrite incoming connection settings proto with our local settings - match: /CONNECTION_OPEN:function\((\i)\){/, - replace: (m, props) => `${m}$self.handleProtoChange(${props}.userSettingsProto,${props}.user);` + match: /function (\i)\((\i)\){(?=.*CONNECTION_OPEN:\1)/, + replace: (m, funcName, props) => `${m}$self.handleProtoChange(${props}.userSettingsProto,${props}.user);` }, { // Overwrite non local proto changes with our local settings diff --git a/src/plugins/favEmojiFirst/index.ts b/src/plugins/favEmojiFirst/index.ts index d1a5458d..aa43a528 100644 --- a/src/plugins/favEmojiFirst/index.ts +++ b/src/plugins/favEmojiFirst/index.ts @@ -57,7 +57,7 @@ export default definePlugin({ { // https://regex101.com/r/x2mobQ/1 // searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length) - match: /,maxCount:(\i)(.{1,500}\i)=(\i)\.slice\(0,(\i-\i\.length)\)/, + match: /,maxCount:(\i)(.{1,500}\i)=(\i)\.slice\(0,(Math\.max\(\i,\i(?:-\i\.length){2})\)/, // ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis) replace: ",maxCount:Infinity$2=($3.sliceTo = $4, $3)" } diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index a79e3f31..3d32d625 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -346,35 +346,35 @@ export default definePlugin({ replacement: [ { // Add deleted=true to all target messages in the MESSAGE_DELETE event - match: /MESSAGE_DELETE:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/, + match: /function (?=.+?MESSAGE_DELETE:(\i))\1\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?}(?=function)/, replace: - "MESSAGE_DELETE:function($1){" + - " var cache = $2getOrCreate($1.channelId);" + - " cache = $self.handleDelete(cache, $1, false);" + - " $2commit(cache);" + - "}," + "function $1($2){" + + " var cache = $3getOrCreate($2.channelId);" + + " cache = $self.handleDelete(cache, $2, false);" + + " $3commit(cache);" + + "}" }, { // Add deleted=true to all target messages in the MESSAGE_DELETE_BULK event - match: /MESSAGE_DELETE_BULK:function\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?},/, + match: /function (?=.+?MESSAGE_DELETE_BULK:(\i))\1\((\i)\){let.+?((?:\i\.){2})getOrCreate.+?}(?=function)/, replace: - "MESSAGE_DELETE_BULK:function($1){" + - " var cache = $2getOrCreate($1.channelId);" + - " cache = $self.handleDelete(cache, $1, true);" + - " $2commit(cache);" + - "}," + "function $1($2){" + + " var cache = $3getOrCreate($2.channelId);" + + " cache = $self.handleDelete(cache, $2, true);" + + " $3commit(cache);" + + "}" }, { // Add current cached content + new edit time to cached message's editHistory - match: /(MESSAGE_UPDATE:function\((\i)\).+?)\.update\((\i)/, + match: /(function (\i)\((\i)\).+?)\.update\((\i)(?=.*MESSAGE_UPDATE:\2)/, replace: "$1" + - ".update($3,m =>" + - " (($2.message.flags & 64) === 64 || $self.shouldIgnore($2.message, true)) ? m :" + - " $2.message.edited_timestamp && $2.message.content !== m.content ?" + - " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($2.message, m)]) :" + + ".update($4,m =>" + + " (($3.message.flags & 64) === 64 || $self.shouldIgnore($3.message, true)) ? m :" + + " $3.message.edited_timestamp && $3.message.content !== m.content ?" + + " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($3.message, m)]) :" + " m" + ")" + - ".update($3" + ".update($4" }, { // fix up key (edit last message) attempting to edit a deleted message @@ -488,12 +488,12 @@ export default definePlugin({ find: '"ReferencedMessageStore"', replacement: [ { - match: /MESSAGE_DELETE:function\((\i)\).+?},/, - replace: "MESSAGE_DELETE:function($1){}," + match: /MESSAGE_DELETE:\i,/, + replace: "MESSAGE_DELETE:()=>{}," }, { - match: /MESSAGE_DELETE_BULK:function\((\i)\).+?},/, - replace: "MESSAGE_DELETE_BULK:function($1){}," + match: /MESSAGE_DELETE_BULK:\i,/, + replace: "MESSAGE_DELETE_BULK:()=>{}," } ] }, diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 6c9102d8..6a438675 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -183,8 +183,8 @@ export default definePlugin({ { find: ".ORIGINAL_POSTER=", replacement: { - match: /\((\i)=\{\}\)\)\[(\i)\.BOT/, - replace: "($1=$self.getTagTypes()))[$2.BOT" + match: /(?=(\i)\[\i\.BOT)/, + replace: "$self.genTagTypes($1);" } }, { @@ -280,8 +280,7 @@ export default definePlugin({ .filter(Boolean); }, - getTagTypes() { - const obj = {}; + genTagTypes(obj) { let i = 100; tags.forEach(({ name }) => { obj[name] = ++i; @@ -291,7 +290,6 @@ export default definePlugin({ obj[`${name}-OP`] = ++i; obj[i] = `${name}-OP`; }); - return obj; }, isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 65ce6136..48ca63d1 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -54,8 +54,8 @@ export default definePlugin({ predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true, replacement: [ { - match: /(?<=MESSAGE_CREATE:function\((\i)\){)/, - replace: (_, props) => `if($self.isBlocked(${props}.message))return;` + match: /(?<=function (\i)\((\i)\){)(?=.*MESSAGE_CREATE:\1)/, + replace: (_, _funcName, props) => `if($self.isBlocked(${props}.message))return;` } ] })) diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 4b98e666..914deaa0 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -74,10 +74,10 @@ export default definePlugin({ // This prevents the Message Requests tab from always hiding due to the previous patch (and is compatible with spam requests) // In short, only the red badge is hidden. Button visibility behavior isn't changed. { - find: ".getSpamChannelsCount()", + find: ".getSpamChannelsCount();return", predicate: () => settings.store.hideMessageRequestsCount, replacement: { - match: /(?<=getSpamChannelsCount\(\),\i=)\i\.getMessageRequestsCount\(\)/, + match: /(?<=getSpamChannelsCount\(\);return )\i\.getMessageRequestsCount\(\)/, replace: "$self.getRealMessageRequestCount()" } }, diff --git a/src/plugins/volumeBooster/index.ts b/src/plugins/volumeBooster/index.ts index 241111d4..c9a08bbc 100644 --- a/src/plugins/volumeBooster/index.ts +++ b/src/plugins/volumeBooster/index.ts @@ -94,7 +94,7 @@ export default definePlugin({ find: "AudioContextSettingsMigrated", replacement: [ { - match: /(?<=isLocalMute\(\i,\i\),volume:.+?volume:)\i(?=})/, + match: /(?<=isLocalMute\(\i,\i\),volume:(\i).+?\i\(\i,\i,)\1(?=\))/, replace: "$&>200?200:$&" }, { @@ -109,7 +109,7 @@ export default definePlugin({ }, // Prevent the MediaEngineStore from overwriting our LocalVolumes above 200 with the ones the Discord Audio Context Settings sync sends { - find: '"MediaEngineStore"', + find: '="MediaEngineStore",', replacement: [ { match: /(\.settings\.audioContextSettings.+?)(\i\[\i\])=(\i\.volume)(.+?setLocalVolume\(\i,).+?\)/, diff --git a/src/plugins/whoReacted/index.tsx b/src/plugins/whoReacted/index.tsx index 24be9bef..bcd07079 100644 --- a/src/plugins/whoReacted/index.tsx +++ b/src/plugins/whoReacted/index.tsx @@ -113,8 +113,8 @@ export default definePlugin({ { find: '"MessageReactionsStore"', replacement: { - match: /(?<=CONNECTION_OPEN:function\(\){)(\i)={}/, - replace: "$&;$self.reactions=$1" + match: /function (\i)\(\){(\i)={}(?=.*CONNECTION_OPEN:\1)/, + replace: "$&;$self.reactions=$2;" } }, {