From 36c15d619e99645b0f8c93a9b0fae9ae8a54a2f0 Mon Sep 17 00:00:00 2001 From: Zordan <92729699+zordythezordan@users.noreply.github.com> Date: Wed, 6 Aug 2025 17:26:00 +0300 Subject: [PATCH 1/2] HideAttachments: correctly support forwarded Messages (#3587) Co-authored-by: V --- .../discord-types/src/common/messages/Message.d.ts | 3 +++ src/plugins/hideAttachments/index.tsx | 11 ++++------- src/plugins/unsuppressEmbeds/index.tsx | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/discord-types/src/common/messages/Message.d.ts b/packages/discord-types/src/common/messages/Message.d.ts index 38010cafb..41de88162 100644 --- a/packages/discord-types/src/common/messages/Message.d.ts +++ b/packages/discord-types/src/common/messages/Message.d.ts @@ -83,6 +83,9 @@ export class Message extends DiscordRecord { channel_id: string; message_id: string; } | undefined; + messageSnapshots: { + message: Message; + }[]; nick: unknown; // probably a string nonce: string | undefined; pinned: boolean; diff --git a/src/plugins/hideAttachments/index.tsx b/src/plugins/hideAttachments/index.tsx index 0198a3e1c..382130575 100644 --- a/src/plugins/hideAttachments/index.tsx +++ b/src/plugins/hideAttachments/index.tsx @@ -25,7 +25,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; import definePlugin from "@utils/types"; -import { MessageSnapshot } from "@vencord/discord-types"; +import { Message } from "@vencord/discord-types"; import { ChannelStore } from "@webpack/common"; const KEY = "HideAttachments_HiddenIds"; @@ -41,6 +41,8 @@ const saveHiddenMessages = (ids: Set) => set(KEY, ids); migratePluginSettings("HideMedia", "HideAttachments"); +const hasMedia = (msg: Message) => msg.attachments.length > 0 || msg.embeds.length > 0 || msg.stickerItems.length > 0; + export default definePlugin({ name: "HideMedia", description: "Hide attachments and embeds for individual messages via hover button", @@ -56,12 +58,7 @@ export default definePlugin({ }], renderMessagePopoverButton(msg) { - // @ts-expect-error - discord-types lags behind discord. - const hasAttachmentsInShapshots = msg.messageSnapshots.some( - (snapshot: MessageSnapshot) => snapshot?.message.attachments.length - ); - - if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInShapshots) return null; + if (!hasMedia(msg) && !msg.messageSnapshots.some(s => hasMedia(s.message))) return null; const isHidden = hiddenMessages.has(msg.id); diff --git a/src/plugins/unsuppressEmbeds/index.tsx b/src/plugins/unsuppressEmbeds/index.tsx index e5f8557f9..9eecd86d7 100644 --- a/src/plugins/unsuppressEmbeds/index.tsx +++ b/src/plugins/unsuppressEmbeds/index.tsx @@ -20,17 +20,18 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { MessageSnapshot } from "@vencord/discord-types"; +import { Channel, Message } from "@vencord/discord-types"; import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common"; const EMBED_SUPPRESSED = 1 << 2; -const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => { +const messageContextMenuPatch: NavContextMenuPatchCallback = ( + children, + { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }: { channel: Channel; message: Message; } +) => { const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0; - const hasEmbedsInSnapshots = messageSnapshots.some( - (snapshot: MessageSnapshot) => snapshot?.message.embeds.length - ); + const hasEmbedsInSnapshots = messageSnapshots.some(s => s.message.embeds.length); if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return; From 6a66b7f54f3ef6693941c024004a163b6639a44c Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Wed, 6 Aug 2025 16:16:07 -0400 Subject: [PATCH 2/2] fix plugins broken by Discord update (#3583) Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Co-authored-by: V --- src/plugins/_api/notices.ts | 4 ++-- src/plugins/reviewDB/index.tsx | 7 ------- src/plugins/showAllMessageButtons/index.ts | 5 +++-- src/plugins/showHiddenChannels/index.tsx | 12 +++--------- src/plugins/superReactionTweaks/index.ts | 4 ++-- src/plugins/vencordToolbox/index.tsx | 4 ++-- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts index f0445924e..89aa1a465 100644 --- a/src/plugins/_api/notices.ts +++ b/src/plugins/_api/notices.ts @@ -33,8 +33,8 @@ export default definePlugin({ replace: "if(Vencord.Api.Notices.currentNotice)return false;$&" }, { - match: /(?<=,NOTICE_DISMISS:function\(\i\){)return null!=(\i)/, - replace: "if($1?.id==\"VencordNotice\")return($1=null,Vencord.Api.Notices.nextNotice(),true);$&" + match: /(?<=function (\i)\(\i\){)return null!=(\i)(?=.+?NOTICE_DISMISS:\1)/, + replace: (m, _, notice) => `if(${notice}?.id=="VencordNotice")return(${notice}=null,Vencord.Api.Notices.nextNotice(),true);${m}` } ] } diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index d8374e6fd..c5c102ae0 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -83,13 +83,6 @@ export default definePlugin({ replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user})," } }, - { - find: ".MODAL,user:", - replacement: { - match: /children:\[(?=[^[]+?shouldShowTooltip:)/, - replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user})," - } - }, { find: ".SIDEBAR,shouldShowTooltip:", replacement: { diff --git a/src/plugins/showAllMessageButtons/index.ts b/src/plugins/showAllMessageButtons/index.ts index 1d6890130..6ac17e5da 100644 --- a/src/plugins/showAllMessageButtons/index.ts +++ b/src/plugins/showAllMessageButtons/index.ts @@ -28,8 +28,9 @@ export default definePlugin({ { find: "#{intl::MESSAGE_UTILITIES_A11Y_LABEL}", replacement: { - match: /isExpanded:\i&&(.+?),/, - replace: "isExpanded:$1," + // isExpanded = isShiftPressed && other conditions... + match: /(?<=(\i)=)\i(?=&&.+?isExpanded:\1)/, + replace: "true" } } ] diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 43cd677e3..78c81d001 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -319,20 +319,14 @@ export default definePlugin({ replacement: [ { // Create a variable for the channel prop - match: /users:\i,maxUsers:\i.+?}=(\i).*?;/, - replace: (m, props) => `${m}let{shcChannel}=${props};` + match: /(function \i\(\i\)\{)([^}]+?hideOverflowCount)/, + replace: "$1let {shcChannel}=arguments[0];$2" }, { // Make Discord always render the plus button if the component is used inside the HiddenChannelLockScreen - match: /\i>0(?=&&.{0,30}Math.min)/, + match: /\i>0(?=&&!\i&&!\i)/, replace: m => `($self.isHiddenChannel(typeof shcChannel!=="undefined"?shcChannel:void 0,true)?true:${m})` }, - { - // Prevent Discord from overwriting the last children with the plus button - // if the overflow amount is <= 0 and the component is used inside the HiddenChannelLockScreen - match: /(?<=\i\.length-)1(?=\]=.{0,60}renderPopout)(?<=(\i)=\i\.length-\i.+?)/, - replace: (_, amount) => `($self.isHiddenChannel(typeof shcChannel!=="undefined"?shcChannel:void 0,true)&&${amount}<=0?0:1)` - }, { // Show only the plus text without overflowed children amount // if the overflow amount is <= 0 and the component is used inside the HiddenChannelLockScreen diff --git a/src/plugins/superReactionTweaks/index.ts b/src/plugins/superReactionTweaks/index.ts index 188f868a5..b8aed4785 100644 --- a/src/plugins/superReactionTweaks/index.ts +++ b/src/plugins/superReactionTweaks/index.ts @@ -42,8 +42,8 @@ export default definePlugin({ { find: ",BURST_REACTION_EFFECT_PLAY", replacement: { - match: /(BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/, - replace: "$1!$self.shouldPlayBurstReaction($2)" + match: /(?<=(\i)=\i=>{.+?)(\i\(\i,\i\))>=\i(?=\).+BURST_REACTION_EFFECT_PLAY:\1)/, + replace: "!$self.shouldPlayBurstReaction($2)" } }, { diff --git a/src/plugins/vencordToolbox/index.tsx b/src/plugins/vencordToolbox/index.tsx index 2f671a238..82cd0284f 100644 --- a/src/plugins/vencordToolbox/index.tsx +++ b/src/plugins/vencordToolbox/index.tsx @@ -140,9 +140,9 @@ export default definePlugin({ patches: [ { - find: "toolbar:function", + find: ".controlButtonWrapper,", replacement: { - match: /(?<=toolbar:function.{0,100}\()\i.Fragment,/, + match: /(?<=function (\i).{0,100}\()\i.Fragment,(?=.+?toolbar:\1\(\))/, replace: "$self.ToolboxFragmentWrapper," } }