From c5541d297d37fd4a737b4d4e1fa2ecf348e1a9d5 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 21:48:12 -0300 Subject: [PATCH] Optimize slowest patches --- src/plugins/_api/notices.ts | 2 +- src/plugins/alwaysAnimate/index.ts | 4 ++-- src/plugins/betterFolders/index.tsx | 4 ++-- src/plugins/betterSettings/index.tsx | 4 ++-- src/plugins/colorSighted/index.ts | 4 ++-- src/plugins/fakeNitro/index.tsx | 4 ++-- src/plugins/ignoreActivities/index.tsx | 8 ++++---- src/plugins/memberCount/index.tsx | 4 ++-- src/plugins/pinDms/index.tsx | 4 ++-- src/plugins/resurrectHome/index.tsx | 4 ++-- src/plugins/showHiddenChannels/index.tsx | 12 ++++++------ src/plugins/spotifyCrack/index.ts | 4 ++-- src/plugins/superReactionTweaks/index.ts | 4 ++-- src/plugins/viewIcons/index.tsx | 4 ++-- 14 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts index 90ae6ded9..0c6f6e1db 100644 --- a/src/plugins/_api/notices.ts +++ b/src/plugins/_api/notices.ts @@ -29,7 +29,7 @@ export default definePlugin({ find: '"NoticeStore"', replacement: [ { - match: /\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, + match: /(?<=!1;)\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, replace: "if(Vencord.Api.Notices.currentNotice)return false;$&" }, { diff --git a/src/plugins/alwaysAnimate/index.ts b/src/plugins/alwaysAnimate/index.ts index dbec3b4e3..20cb4f974 100644 --- a/src/plugins/alwaysAnimate/index.ts +++ b/src/plugins/alwaysAnimate/index.ts @@ -31,10 +31,10 @@ export default definePlugin({ // Some modules match the find but the replacement is returned untouched noWarn: true, replacement: { - match: /canAnimate:.+?(?=([,}].*?\)))/g, + match: /canAnimate:.+?([,}].*?\))/g, replace: (m, rest) => { const destructuringMatch = rest.match(/}=.+/); - if (destructuringMatch == null) return "canAnimate:!0"; + if (destructuringMatch == null) return `canAnimate:!0${rest}`; return m; } } diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 795f19901..38e1b8412 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -112,8 +112,8 @@ export default definePlugin({ replacement: [ // Create the isBetterFolders variable in the GuildsBar component { - match: /(?<=let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?)(?=}=\i,)/, - replace: ",isBetterFolders" + match: /let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?(?=}=\i,)/, + replace: "$&,isBetterFolders" }, // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { diff --git a/src/plugins/betterSettings/index.tsx b/src/plugins/betterSettings/index.tsx index e90e5c82a..e0267e4b0 100644 --- a/src/plugins/betterSettings/index.tsx +++ b/src/plugins/betterSettings/index.tsx @@ -111,8 +111,8 @@ export default definePlugin({ { // Load menu TOC eagerly find: "Messages.USER_SETTINGS_WITH_BUILD_OVERRIDE.format", replacement: { - match: /(?<=(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?openContextMenuLazy.{0,100}?(await Promise\.all[^};]*?\)\)).*?,)(?=\1\(this)/, - replace: "(async ()=>$2)()," + match: /(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?openContextMenuLazy.{0,100}?(await Promise\.all[^};]*?\)\)).*?,(?=\1\(this)/, + replace: "$&(async ()=>$2)()," }, predicate: () => settings.store.eagerLoad }, diff --git a/src/plugins/colorSighted/index.ts b/src/plugins/colorSighted/index.ts index d741aaae6..025cfb94e 100644 --- a/src/plugins/colorSighted/index.ts +++ b/src/plugins/colorSighted/index.ts @@ -34,9 +34,9 @@ export default definePlugin({ { find: ".AVATAR_STATUS_MOBILE_16;", replacement: { - match: /(?<=fromIsMobile:\i=!0,.+?)status:(\i)/, + match: /(fromIsMobile:\i=!0,.+?)status:(\i)/, // Rename field to force it to always use "online" - replace: 'status_$:$1="online"' + replace: '$1status_$:$2="online"' } } ] diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 9c8af1e7c..4ab0e18ee 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -344,8 +344,8 @@ export default definePlugin({ { // Patch the stickers array to add fake nitro stickers predicate: () => settings.store.transformStickers, - match: /(?<=renderStickersAccessories\((\i)\){let (\i)=\(0,\i\.\i\)\(\i\).+?;)/, - replace: (_, message, stickers) => `${stickers}=$self.patchFakeNitroStickers(${stickers},${message});` + match: /renderStickersAccessories\((\i)\){let (\i)=\(0,\i\.\i\)\(\i\).+?;/, + replace: (m, message, stickers) => `${m}${stickers}=$self.patchFakeNitroStickers(${stickers},${message});` }, { // Filter attachments to remove fake nitro stickers or emojis diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index e2262129d..f687a0caf 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -228,15 +228,15 @@ export default definePlugin({ { find: ".activityTitleText,variant", replacement: { - match: /(?<=\i\.activityTitleText.+?children:(\i)\.name.*?}\),)/, - replace: (_, props) => `$self.renderToggleActivityButton(${props}),` + match: /\.activityTitleText.+?children:(\i)\.name.*?}\),/, + replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` }, }, { find: ".activityCardDetails,children", replacement: { - match: /(?<=\i\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),)/, - replace: (_, props) => `$self.renderToggleActivityButton(${props}),` + match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/, + replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` } } ], diff --git a/src/plugins/memberCount/index.tsx b/src/plugins/memberCount/index.tsx index 92e9a2057..28ecb9db7 100644 --- a/src/plugins/memberCount/index.tsx +++ b/src/plugins/memberCount/index.tsx @@ -70,8 +70,8 @@ export default definePlugin({ { find: ".invitesDisabledTooltip", replacement: { - match: /(?<=\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100})]/, - replace: ",$self.renderTooltip(arguments[0].guild)]" + match: /\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100}(?=])/, + replace: "$&,$self.renderTooltip(arguments[0].guild)" }, predicate: () => settings.store.toolTip } diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 60484561a..033552593 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -111,8 +111,8 @@ export default definePlugin({ replace: "$self.getScrollOffset(arguments[0],$1,this.props.padding,this.state.preRenderedChildren,$&)" }, { - match: /(?<=scrollToChannel\(\i\){.{1,300})this\.props\.privateChannelIds/, - replace: "[...$&,...$self.getAllUncollapsedChannels()]" + match: /(scrollToChannel\(\i\){.{1,300})(this\.props\.privateChannelIds)/, + replace: "$1[...$2,...$self.getAllUncollapsedChannels()]" }, ] diff --git a/src/plugins/resurrectHome/index.tsx b/src/plugins/resurrectHome/index.tsx index 70827e08f..5193090ea 100644 --- a/src/plugins/resurrectHome/index.tsx +++ b/src/plugins/resurrectHome/index.tsx @@ -134,8 +134,8 @@ export default definePlugin({ { find: '"MessageActionCreators"', replacement: { - match: /(?<=focusMessage\(\i\){.+?)(?=focus:{messageId:(\i)})/, - replace: "after:$1," + match: /focusMessage\(\i\){.+?(?=focus:{messageId:(\i)})/, + replace: "$&after:$1," } }, // Force Server Home instead of Server Guide diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index f08bc2d1d..c120d72d8 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -89,8 +89,8 @@ export default definePlugin({ }, // Remove permission checking for getRenderLevel function { - match: /(?<=getRenderLevel\(\i\){.+?return)!\i\.\i\.can\(\i\.\i\.VIEW_CHANNEL,this\.record\)\|\|/, - replace: " " + match: /(getRenderLevel\(\i\){.+?return)!\i\.\i\.can\(\i\.\i\.VIEW_CHANNEL,this\.record\)\|\|/, + replace: (_, rest) => `${rest} ` } ] }, @@ -159,8 +159,8 @@ export default definePlugin({ replacement: [ // Make the channel appear as muted if it's hidden { - match: /(?<={channel:(\i),name:\i,muted:(\i).+?;)/, - replace: (_, channel, muted) => `${muted}=$self.isHiddenChannel(${channel})?true:${muted};` + match: /{channel:(\i),name:\i,muted:(\i).+?;/, + replace: (m, channel, muted) => `${m}${muted}=$self.isHiddenChannel(${channel})?true:${muted};` }, // Add the hidden eye icon if the channel is hidden { @@ -186,8 +186,8 @@ export default definePlugin({ { // Hide unreads predicate: () => settings.store.hideUnreads === true, - match: /(?<={channel:(\i),name:\i,.+?unread:(\i).+?;)/, - replace: (_, channel, unread) => `${unread}=$self.isHiddenChannel(${channel})?false:${unread};` + match: /{channel:(\i),name:\i,.+?unread:(\i).+?;/, + replace: (m, channel, unread) => `${m}${unread}=$self.isHiddenChannel(${channel})?false:${unread};` } ] }, diff --git a/src/plugins/spotifyCrack/index.ts b/src/plugins/spotifyCrack/index.ts index 1beccad60..37504be2e 100644 --- a/src/plugins/spotifyCrack/index.ts +++ b/src/plugins/spotifyCrack/index.ts @@ -60,8 +60,8 @@ export default definePlugin({ }, { predicate: () => settings.store.keepSpotifyActivityOnIdle, - match: /(?<=shouldShowActivity\(\){.{0,50})&&!\i\.\i\.isIdle\(\)/, - replace: "" + match: /(shouldShowActivity\(\){.{0,50})&&!\i\.\i\.isIdle\(\)/, + replace: "$1" } ] } diff --git a/src/plugins/superReactionTweaks/index.ts b/src/plugins/superReactionTweaks/index.ts index 89197b4c3..7878ba630 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: "!$self.shouldPlayBurstReaction($1)" + match: /(BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/, + replace: "$1!$self.shouldPlayBurstReaction($2)" } }, { diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 359365ee4..09254d511 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -206,8 +206,8 @@ export default definePlugin({ { find: ".avatarPositionPanel", replacement: { - match: /(?<=avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, - replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}" + match: /(avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, + replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" } }, // Group DMs top small & large icon