From 186e7b5595c5a0fd0aaf06a9be54e5f5f98d8f0c Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 21 Apr 2025 23:30:40 -0400 Subject: [PATCH] Patches --- src/equicordplugins/channelTabs/index.tsx | 2 +- .../_api/memberListDecorators/index.tsx | 6 +++- .../accountPanelServerProfile/index.tsx | 19 ++++++----- src/plugins/betterFolders/index.tsx | 33 ++++++++++++------- src/plugins/forceOwnerCrown/index.ts | 3 +- src/plugins/noUnblockToJump/README.md | 5 --- src/plugins/noUnblockToJump/index.ts | 2 +- src/plugins/reviewDB/index.tsx | 3 +- src/plugins/showHiddenChannels/index.tsx | 14 ++++---- 9 files changed, 51 insertions(+), 36 deletions(-) delete mode 100644 src/plugins/noUnblockToJump/README.md diff --git a/src/equicordplugins/channelTabs/index.tsx b/src/equicordplugins/channelTabs/index.tsx index f6895140..6c5aaf10 100644 --- a/src/equicordplugins/channelTabs/index.tsx +++ b/src/equicordplugins/channelTabs/index.tsx @@ -48,7 +48,7 @@ export default definePlugin({ { find: ".COLLECTIBLES_SHOP_FULLSCREEN))", replacement: { - match: /(\?void 0:(\i)\.channelId.{0,300}return)((.{0,15})"div",{.*?\])(\}\)\}\})/, + match: /(\?void 0:(\i)\.channelId.{0,500}return)((.{0,15})"div",{.*?\])(\}\)\}\})/, replace: "$1$4$self.render,{currentChannel:$2,children:$3})$5" } }, diff --git a/src/plugins/_api/memberListDecorators/index.tsx b/src/plugins/_api/memberListDecorators/index.tsx index 365c21f3..3f76a42f 100644 --- a/src/plugins/_api/memberListDecorators/index.tsx +++ b/src/plugins/_api/memberListDecorators/index.tsx @@ -36,9 +36,13 @@ export default definePlugin({ match: /let\{[^}]*lostPermissionTooltipText:\i[^}]*\}=(\i),/, replace: "$&vencordProps=$1," }, + { + match: /decorators:.{0,100}?(?=user:)/, + replace: "$&vencordProps:typeof vencordProps!=='undefined'?vencordProps:void 0," + }, { match: /children:\[(?=.{0,300},lostPermissionTooltipText:)/, - replace: "children:[(typeof vencordProps!=='undefined'&&Vencord.Api.MemberListDecorators.__getDecorators(vencordProps))," + replace: "children:[(arguments[0]?.vencordProps&&Vencord.Api.MemberListDecorators.__getDecorators(arguments[0].vencordProps))," } ] }, diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index 8b561581..536cf6e4 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(".BITE_SIZE,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/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 2d8bf360..4143d293 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -124,27 +124,42 @@ export default definePlugin({ replacement: [ // Create the isBetterFolders variable in the GuildsBar component { - match: /let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?(?=}=\i,)/, + match: /let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?(?=}=\i,)/g, replace: "$&,isBetterFolders" }, // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { - match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/, + match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/g, replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0]?.isBetterFolders,betterFoldersOriginalTree,arguments[0]?.betterFoldersExpandedIds)` }, // If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children { - match: /lastTargetNode:\i\[\i\.length-1\].+?}\)(?::null)?\](?=}\))/, + match: /lastTargetNode:\i\[\i\.length-1\].+?}\)(?::null)?\](?=}\))/g, replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))" }, // If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children + // As of now, this is just the unread indicator at the bottom + // Discord has two different sidebars controlled by an experiment + // only the second one needs this filter { - match: /unreadMentionsIndicatorBottom,.+?}\)\]/, + match: /topSection.+?unreadMentionsIndicatorBottom,.+?}\)\]/, replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))" }, + // With one of the sidebar versions, there is a sticky top bar. Don't render it if we are rendering the Better Folders sidebar + { + // [^0] to not match any other JSX call + match: /(?=\(0,\i\.jsxs?\)[^0]+\.topSection)/, + replace: "!!arguments[0]?.isBetterFolders?null:" + }, + // Don't render the tiny separator line at the top of the Better Folders sidebar + // Only needed with the sidebar variant with the sticky top bar + { + match: /(?=\(0,\i\.jsxs?\)[^0]+fullWidth:)/, + replace: "!!arguments[0]?.isBetterFolders?null:" + }, // Export the isBetterFolders variable to the folders component { - match: /switch\(\i\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,/, + match: /switch\(\i\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,/g, replace: '$&isBetterFolders:typeof isBetterFolders!=="undefined"?isBetterFolders:false,' } ] @@ -327,13 +342,7 @@ export default definePlugin({ return child => { if (!isBetterFolders) return true; - if (child?.props?.className?.includes("itemsContainer") && child.props.children != null) { - // Filter out everything but the scroller for the guild list - child.props.children = child.props.children.filter(child => child?.props?.onScroll != null); - return true; - } - - return false; + return child?.props?.className?.includes("itemsContainer") && child.props.children != null; }; }, diff --git a/src/plugins/forceOwnerCrown/index.ts b/src/plugins/forceOwnerCrown/index.ts index 907d9dc0..df0243d8 100644 --- a/src/plugins/forceOwnerCrown/index.ts +++ b/src/plugins/forceOwnerCrown/index.ts @@ -29,7 +29,8 @@ export default definePlugin({ { find: "#{intl::GUILD_OWNER}),children:", replacement: { - match: /,isOwner:(\i),/, + // The isOwner prop is used in more tha one component in this module. Make sure we patch the right one + match: /,isOwner:(\i),(?=[^}]+guildId)/, replace: ",_isOwner:$1=$self.isGuildOwner(e)," } } diff --git a/src/plugins/noUnblockToJump/README.md b/src/plugins/noUnblockToJump/README.md deleted file mode 100644 index 326bca3b..00000000 --- a/src/plugins/noUnblockToJump/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# No Unblock To Jump - -Removes the popup preventing you to jump to a message from a blocked/ignored user (eg: in search results) - -![A modal popup telling you to unblock a user to jump their message](https://github.com/user-attachments/assets/0e4b859d-f3b3-4101-9a83-829afb473d1e) diff --git a/src/plugins/noUnblockToJump/index.ts b/src/plugins/noUnblockToJump/index.ts index 04ddf2ed..4dbbe462 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" }, { diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 822ebde6..858b82f3 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -91,7 +91,8 @@ export default definePlugin({ } }, { - find: 'location:"UserProfilePanel"', + // location: "UserProfileSiebar" + find: ".PANEL,children:[", replacement: { match: /{profileType:\i\.\i\.PANEL,children:\[/, replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user})," diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 08f7fbf1..21598633 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -357,7 +357,7 @@ export default definePlugin({ ] }, { - find: '})},"overflow"))', + find: "overflowCountVariant", replacement: [ { // Create a variable for the channel prop @@ -366,17 +366,19 @@ export default definePlugin({ }, { // Make Discord always render the plus button if the component is used inside the HiddenChannelLockScreen - match: /\i>0(?=&&.{0,60}renderPopout)/, + match: /\i>0(?=&&.{0,60}Math.min)/, 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: /(?<=\.value\(\),(\i)=.+?length-)1(?=\]=.{0,60}renderPopout)/, + // 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 - match: /(?<="\+",)(\i)\+1/, + // Show only the plus text without overflowed children amount + // if the overflow amount is <= 0 and the component is used inside the HiddenChannelLockScreen + match: /(?<="\+"\.concat\()(\i)/, replace: (m, amount) => `$self.isHiddenChannel(typeof shcChannel!=="undefined"?shcChannel:void 0,true)&&${amount}<=0?"":${m}` } ]