From 943c6fe0249af2345496a673aab724074d6d032d Mon Sep 17 00:00:00 2001 From: Etorix <92535668+EtorixDev@users.noreply.github.com> Date: Fri, 29 Aug 2025 06:04:24 -0700 Subject: [PATCH] Fix patches. (#367) --- src/equicordplugins/downloadify/index.tsx | 10 +++----- src/plugins/showMeYourName/index.tsx | 29 +++++++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/equicordplugins/downloadify/index.tsx b/src/equicordplugins/downloadify/index.tsx index f27bdf8d4..4e612f2f6 100644 --- a/src/equicordplugins/downloadify/index.tsx +++ b/src/equicordplugins/downloadify/index.tsx @@ -91,16 +91,12 @@ export default definePlugin({ replacement: [ { // Make use of the download function. - match: /(let{item:\i}=(\i).{0,450}?)(let \i=)(await \i.\i.saveImage\(\i,\i.contentType,\i.\i\))/, - replace: "$1await $self.handleExpandedModalDownloadButtonClicked($2,async()=>{$4})", - }, - { - match: /if\(\i===.{0,100}\(\i\)\);/, - replace: "" + match: /(let{item:\i}=(\i).{0,450}?)let \i=(await \i.\i.saveImage\(\i,\i.contentType,\i.\i\)).{0,110}?&&/, + replace: "$1await $self.handleExpandedModalDownloadButtonClicked($2,async()=>{$3});", }, { // Disable default success toast. - match: /\i===\i\.\i\.SAVED&&\(\(0,.{0,85}?ToastType.SUCCESS\)\)\)/, + match: /\(\(0,.{0,85}?ToastType.SUCCESS\)\)\)/, replace: "", }, { diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index cd82c9c4d..3700cef94 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -768,18 +768,27 @@ export default definePlugin({ patches: [ { find: '="SYSTEM_TAG"', - replacement: { - // Replace names in messages and replies. - match: /(onContextMenu:\i,children:)(.{0,250}?),"data-text":(\i\+\i)/, - replace: "$1$self.getMessageNameElement(arguments[0])??($2),\"data-text\":$self.getMessageNameText(arguments[0])??($3)" - } + group: true, + replacement: [ + { + // Replace names in messages and replies. + match: /(onContextMenu:\i,children:)(.{0,250}?),"data-text":(\i\+\i)/, + replace: "$1$self.getMessageNameElement(arguments[0])??($2),\"data-text\":$self.getMessageNameText(arguments[0])??($3)" + }, + { + // Pass the message object to the should-animate checker. + match: /(\(\{)(shouldSubscribe)/, + replace: "$1message:arguments[0].message,$2" + } + ] }, { find: /setAnimate.{0,50}\.ANIMATE_CHAT_AVATAR,/, replacement: { - // Animate gradients for message authors. + // Track hovering on messages to animate names since Discord's + // built-in hover tracking is buggy. Used by a patch below. match: /(let{setAnimate:\i}=(\i);)/, - replace: "$1if($2.animate){$self.addHoveringMessage(arguments[0].message.id)}else{$self.removeHoveringMessage(arguments[0].message.id)};" + replace: "$1if(arguments[0].message){if($2.animate){$self.addHoveringMessage(arguments[0].message.id)}else{$self.removeHoveringMessage(arguments[0].message.id)}};" } }, { @@ -810,9 +819,9 @@ export default definePlugin({ // Track hovering over second-level messages to animate gradients. // Tack on the groupId, which is how the client groups messages from // the same author together, to the message temporarily so that mentions - // across a group can animate together. By default, Discord handles this - // by animating the second-level message if you are hovering the first-level - // message, but not the other way around. This patch allows both. + // across a group can animate together. By default, Discord handles this, + // but moving between messages can cause a race condition where the animation + // stops on one of the messages in the group. This patch fixes that. find: "CUSTOM_GIFT?\"\":", replacement: { match: /(\(\i,\i,\i\);)(let \i=\i.id===\i(?:.{0,500}?)hovering:(\i))/,