From cf78ddcfe27e48d3c49e6a12a4bf1834ae6ea29c Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Wed, 23 Apr 2025 14:36:43 -0400 Subject: [PATCH] fix plugins for latest discord update (#3387) Co-authored-by: Vendicated --- src/api/MemberListDecorators.tsx | 31 ++++++------------- src/plugins/_api/badges/index.tsx | 2 +- .../_api/memberListDecorators/index.tsx | 10 ++---- src/plugins/_api/serverList.ts | 4 +-- .../accountPanelServerProfile/index.tsx | 19 +++++++----- src/plugins/forceOwnerCrown/index.ts | 4 +-- src/plugins/friendsSince/index.tsx | 2 +- src/plugins/ircColors/index.ts | 4 +-- src/plugins/mutualGroupDMs/index.tsx | 8 +++++ src/plugins/mutualGroupDMs/style.css | 4 +++ src/plugins/noUnblockToJump/index.ts | 2 +- 11 files changed, 44 insertions(+), 46 deletions(-) create mode 100644 src/plugins/mutualGroupDMs/style.css diff --git a/src/api/MemberListDecorators.tsx b/src/api/MemberListDecorators.tsx index ab5a618bf..ada60776e 100644 --- a/src/api/MemberListDecorators.tsx +++ b/src/api/MemberListDecorators.tsx @@ -21,25 +21,14 @@ import { Channel, User } from "discord-types/general/index.js"; import { JSX } from "react"; interface DecoratorProps { - activities: any[]; - channel: Channel; - /** - * Only for DM members - */ - channelName?: string; - /** - * Only for server members - */ - currentUser?: User; - guildId?: string; - isMobile: boolean; - isOwner?: boolean; - isTyping: boolean; - selected: boolean; - status: string; + type: "guild" | "dm"; user: User; - [key: string]: any; + /** only present when this is a DM list item */ + channel: Channel; + /** only present when this is a guild list item */ + isOwner: boolean; } + export type MemberListDecoratorFactory = (props: DecoratorProps) => JSX.Element | null; type OnlyIn = "guilds" | "dms"; @@ -53,18 +42,16 @@ export function removeMemberListDecorator(identifier: string) { decoratorsFactories.delete(identifier); } -export function __getDecorators(props: DecoratorProps): JSX.Element { - const isInGuild = !!(props.guildId); - +export function __getDecorators(props: DecoratorProps, type: "guild" | "dm"): JSX.Element { const decorators = Array.from( decoratorsFactories.entries(), ([key, { render: Decorator, onlyIn }]) => { - if ((onlyIn === "guilds" && !isInGuild) || (onlyIn === "dms" && isInGuild)) + if ((onlyIn === "guilds" && type !== "guild") || (onlyIn === "dms" && type !== "dm")) return null; return ( - + ); } diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index e63073ce8..52bede447 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -63,7 +63,7 @@ export default definePlugin({ required: true, patches: [ { - find: ".FULL_SIZE]:26", + find: ".MODAL]:26", replacement: { match: /(?=;return 0===(\i)\.length\?)(?<=(\i)\.useMemo.+?)/, replace: ";$1=$2.useMemo(()=>[...$self.getBadges(arguments[0].displayProfile),...$1],[$1])" diff --git a/src/plugins/_api/memberListDecorators/index.tsx b/src/plugins/_api/memberListDecorators/index.tsx index 365c21f38..90f09d8fa 100644 --- a/src/plugins/_api/memberListDecorators/index.tsx +++ b/src/plugins/_api/memberListDecorators/index.tsx @@ -32,21 +32,17 @@ export default definePlugin({ { find: ".lostPermission)", replacement: [ - { - match: /let\{[^}]*lostPermissionTooltipText:\i[^}]*\}=(\i),/, - replace: "$&vencordProps=$1," - }, { match: /children:\[(?=.{0,300},lostPermissionTooltipText:)/, - replace: "children:[(typeof vencordProps!=='undefined'&&Vencord.Api.MemberListDecorators.__getDecorators(vencordProps))," + replace: "children:[Vencord.Api.MemberListDecorators.__getDecorators(arguments[0],'guild')," } ] }, { find: "PrivateChannel.renderAvatar", replacement: { - match: /decorators:(\i\.isSystemDM\(\))\?(.+?):null/, - replace: "decorators:[Vencord.Api.MemberListDecorators.__getDecorators(arguments[0]),$1?$2:null]" + match: /decorators:(\i\.isSystemDM\(\)\?.+?:null)/, + replace: "decorators:[Vencord.Api.MemberListDecorators.__getDecorators(arguments[0],'dm'),$1]" } } ] diff --git a/src/plugins/_api/serverList.ts b/src/plugins/_api/serverList.ts index dfd40de74..89c407964 100644 --- a/src/plugins/_api/serverList.ts +++ b/src/plugins/_api/serverList.ts @@ -32,9 +32,9 @@ export default definePlugin({ } }, { - find: "#{intl::SERVERS}),children", + find: ".setGuildsTree(", replacement: { - match: /(?<=#{intl::SERVERS}\),children:)\i\.map\(\i\)/, + match: /(?<=#{intl::SERVERS}\),gap:"xs",children:)\i\.map\(.{0,50}\.length\)/, replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)" } } diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index 8b561581c..ad63ba27a 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -9,7 +9,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { getCurrentChannel } from "@utils/discord"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { findComponentByCodeLazy } from "@webpack"; import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common"; import { User } from "discord-types/general"; @@ -19,8 +19,7 @@ interface UserProfileProps { originalRenderPopout: () => React.ReactNode; } -const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); -const styles = findByPropsLazy("accountProfilePopoutWrapper"); +const UserProfile = findComponentByCodeLazy(".POPOUT,user"); let openAlternatePopout = false; let accountPanelRef: React.RefObject | null> = { current: null }; @@ -77,7 +76,7 @@ export default definePlugin({ replace: "$self.useAccountPanelRef();$&" }, { - match: /(\.AVATAR,children:.+?renderPopout:(\(\i,\i\))=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, + match: /(\.AVATAR,children:.+?renderPopout:\((\i),\i\)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})` }, { @@ -121,14 +120,18 @@ export default definePlugin({ } const currentChannel = getCurrentChannel(); - if (currentChannel?.getGuildId() == null) { + if (currentChannel?.getGuildId() == null || !UserProfile.$$vencordGetWrappedComponent()) { return originalRenderPopout(); } return ( -
- -
+ ); }, { noop: true }) }); diff --git a/src/plugins/forceOwnerCrown/index.ts b/src/plugins/forceOwnerCrown/index.ts index 907d9dc02..bf115c642 100644 --- a/src/plugins/forceOwnerCrown/index.ts +++ b/src/plugins/forceOwnerCrown/index.ts @@ -29,8 +29,8 @@ export default definePlugin({ { find: "#{intl::GUILD_OWNER}),children:", replacement: { - match: /,isOwner:(\i),/, - replace: ",_isOwner:$1=$self.isGuildOwner(e)," + match: /(?<=decorators:.{0,200}?isOwner:)\i/, + replace: "$self.isGuildOwner(arguments[0])" } } ], diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 0f4016ad6..07723bcc1 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -24,7 +24,7 @@ export default definePlugin({ patches: [ // DM User Sidebar { - find: ".PANEL}),nicknameIcons", + find: ".SIDEBAR}),nicknameIcons", replacement: { match: /#{intl::USER_PROFILE_MEMBER_SINCE}\),.{0,100}userId:(\i\.id)}\)}\)/, replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:true})" diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts index 3e0515f52..d4f453a78 100644 --- a/src/plugins/ircColors/index.ts +++ b/src/plugins/ircColors/index.ts @@ -66,8 +66,8 @@ export default definePlugin({ { find: '="SYSTEM_TAG"', replacement: { - match: /\i.gradientClassName]\),style:/, - replace: "$&{color:$self.calculateNameColorForMessageContext(arguments[0])},_style:" + match: /(?<=\.username.{0,50}?)style:/, + replace: "style:{color:$self.calculateNameColorForMessageContext(arguments[0])},_style:" } }, { diff --git a/src/plugins/mutualGroupDMs/index.tsx b/src/plugins/mutualGroupDMs/index.tsx index 1c9ad40ec..d71fd9339 100644 --- a/src/plugins/mutualGroupDMs/index.tsx +++ b/src/plugins/mutualGroupDMs/index.tsx @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import "./style.css"; + import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { isNonNullish } from "@utils/guards"; @@ -95,6 +97,12 @@ export default definePlugin({ { match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/, replace: "$1==='MUTUAL_GDMS'?$self.renderMutualGDMs(arguments[0]):$&" + }, + // Discord adds spacing between each item which pushes our tab off screen. + // set the gap to zero to ensure ours stays on screen + { + match: /className:\i\.tabBar/, + replace: "$& + ' vc-mutual-gdms-tab-bar'" } ] }, diff --git a/src/plugins/mutualGroupDMs/style.css b/src/plugins/mutualGroupDMs/style.css new file mode 100644 index 000000000..14ea83c9d --- /dev/null +++ b/src/plugins/mutualGroupDMs/style.css @@ -0,0 +1,4 @@ +.vc-mutual-gdms-tab-bar { + gap: 0; + justify-content: space-between; +} diff --git a/src/plugins/noUnblockToJump/index.ts b/src/plugins/noUnblockToJump/index.ts index 04ddf2ed3..4dbbe4628 100644 --- a/src/plugins/noUnblockToJump/index.ts +++ b/src/plugins/noUnblockToJump/index.ts @@ -30,7 +30,7 @@ export default definePlugin({ find: '.id,"Search Results"', replacement: [ { - match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, + match: /if\(.{1,40}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, replace: "if(false)$1" }, {