Fix patches. (#367)

This commit is contained in:
Etorix 2025-08-29 06:04:24 -07:00 • committed by GitHub
parent 508dce22eb
commit 943c6fe024
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 17 deletions

View file

@ -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: "",
},
{

View file

@ -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))/,