From d19b0aeb5be368689c0e81de3a1c014326146840 Mon Sep 17 00:00:00 2001 From: vee Date: Wed, 19 Jun 2024 04:36:21 +0200 Subject: [PATCH] second batch of fixes (#2596) Co-authored-by: programminglaboratorys <107296738+programminglaboratorys@users.noreply.github.com> Co-authored-by: Haruka Co-authored-by: Amia <9750071+aamiaa@users.noreply.github.com> Co-authored-by: AutumnVN Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> --- src/plugins/_api/chatButtons.ts | 4 ++-- src/plugins/_api/messageEvents.ts | 2 +- src/plugins/banger/index.ts | 2 +- src/plugins/betterFolders/index.tsx | 12 ++++++------ src/plugins/betterGifPicker/index.ts | 2 +- src/plugins/ctrlEnterSend/index.ts | 4 ++-- src/plugins/decor/index.tsx | 8 +++----- src/plugins/disableCallIdle/index.ts | 2 +- src/plugins/favEmojiFirst/index.ts | 2 +- src/plugins/index.ts | 7 +------ src/plugins/maskedLinkPaste/index.ts | 14 ++++++++------ src/plugins/noBlockedMessages/index.ts | 12 ++++++++++-- src/plugins/noDefaultHangStatus/index.ts | 2 +- src/plugins/noMosaic/index.ts | 2 +- src/plugins/openInApp/index.ts | 4 ++-- src/plugins/pauseInvitesForever/index.tsx | 6 +++--- src/plugins/replyTimestamp/index.tsx | 12 +++++++----- src/plugins/roleColorEverywhere/index.tsx | 2 +- src/plugins/showMeYourName/index.tsx | 2 +- src/plugins/usrbg/index.tsx | 20 +++++--------------- 20 files changed, 58 insertions(+), 63 deletions(-) diff --git a/src/plugins/_api/chatButtons.ts b/src/plugins/_api/chatButtons.ts index 1ec2fa25..578861e2 100644 --- a/src/plugins/_api/chatButtons.ts +++ b/src/plugins/_api/chatButtons.ts @@ -15,8 +15,8 @@ export default definePlugin({ patches: [{ find: '"sticker")', replacement: { - match: /!\i\.isMobile(?=.+?(\i)\.push\(.{0,50}"gift")/, - replace: "$& &&(Vencord.Api.ChatButtons._injectButtons($1,arguments[0]),true)" + match: /return\(!\i\.\i&&(?=\(\i\.isDM.+?(\i)\.push\(.{0,50}"gift")/, + replace: "$&(Vencord.Api.ChatButtons._injectButtons($1,arguments[0]),true)&&" } }] }); diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index 48ae062c..2f31398c 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -39,7 +39,7 @@ export default definePlugin({ replacement: { // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, + match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.\i\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + `${rest1}async ${rest2}` + diff --git a/src/plugins/banger/index.ts b/src/plugins/banger/index.ts index dd9b4c82..11ced3bd 100644 --- a/src/plugins/banger/index.ts +++ b/src/plugins/banger/index.ts @@ -27,7 +27,7 @@ export default definePlugin({ { find: "BAN_CONFIRM_TITLE.", replacement: { - match: /src:\i\("\d+"\)/g, + match: /src:\i\(\d+\)/g, replace: "src: Vencord.Settings.plugins.BANger.source" } } diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 38e1b841..59e55111 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -19,7 +19,7 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; +import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; import { FluxDispatcher, i18n, useMemo } from "@webpack/common"; import FolderSideBar from "./FolderSideBar"; @@ -30,7 +30,7 @@ enum FolderIconDisplay { MoreThanOneFolderExpanded } -const { GuildsTree } = findByPropsLazy("GuildsTree"); +const GuildsTree = findLazy(m => m.prototype?.moveNextTo); const SortedGuildStore = findStoreLazy("SortedGuildStore"); export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand"); @@ -117,7 +117,7 @@ export default definePlugin({ }, // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { - match: /\[(\i)\]=(\(0,\i\.useStateFromStoresArray\).{0,40}getGuildsTree\(\).+?}\))(?=,)/, + match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/, 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 @@ -139,12 +139,12 @@ export default definePlugin({ }, { // This is the parent folder component - find: ".MAX_GUILD_FOLDER_NAME_LENGTH,", + find: ".toggleGuildFolderExpand(", predicate: () => settings.store.sidebar && settings.store.showFolderIcon !== FolderIconDisplay.Always, replacement: [ { // Modify the expanded state to instead return the list of expanded folders - match: /(useStateFromStores\).{0,20}=>)(\i\.\i)\.isFolderExpanded\(\i\)/, + match: /(\i\).{0,20}=>)(\i\.\i)\.isFolderExpanded\(\i\)/, replace: (_, rest, ExpandedGuildFolderStore) => `${rest}${ExpandedGuildFolderStore}.getExpandedFolders()`, }, { @@ -196,7 +196,7 @@ export default definePlugin({ ] }, { - find: "APPLICATION_LIBRARY,render", + find: "APPLICATION_LIBRARY,render:", predicate: () => settings.store.sidebar, replacement: { // Render the Better Folders sidebar diff --git a/src/plugins/betterGifPicker/index.ts b/src/plugins/betterGifPicker/index.ts index f1608f28..9d7d8db4 100644 --- a/src/plugins/betterGifPicker/index.ts +++ b/src/plugins/betterGifPicker/index.ts @@ -13,7 +13,7 @@ export default definePlugin({ authors: [Devs.Samwich], patches: [ { - find: ".GIFPickerResultTypes.SEARCH", + find: '"state",{resultType:', replacement: [{ match: /(?<="state",{resultType:)null/, replace: '"Favorites"' diff --git a/src/plugins/ctrlEnterSend/index.ts b/src/plugins/ctrlEnterSend/index.ts index 817da053..ee218060 100644 --- a/src/plugins/ctrlEnterSend/index.ts +++ b/src/plugins/ctrlEnterSend/index.ts @@ -40,9 +40,9 @@ export default definePlugin({ }), patches: [ { - find: "KeyboardKeys.ENTER&&(!", + find: ".ENTER&&(!", replacement: { - match: /(?<=(\i)\.which===\i\.KeyboardKeys.ENTER&&).{0,100}(\(0,\i\.hasOpenPlainTextCodeBlock\)\(\i\)).{0,100}(?=&&\(\i\.preventDefault)/, + match: /(?<=(\i)\.which===\i\.\i.ENTER&&).{0,100}(\(0,\i\.\i\)\(\i\)).{0,100}(?=&&\(\i\.preventDefault)/, replace: "$self.shouldSubmit($1, $2)" } } diff --git a/src/plugins/decor/index.tsx b/src/plugins/decor/index.tsx index 5b2b6d0f..fe1f6dcb 100644 --- a/src/plugins/decor/index.tsx +++ b/src/plugins/decor/index.tsx @@ -9,7 +9,6 @@ import "./ui/styles.css"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { findByPropsLazy } from "@webpack"; import { UserStore } from "@webpack/common"; import { CDN_URL, RAW_SKU_ID, SKU_ID } from "./lib/constants"; @@ -20,7 +19,6 @@ import { settings } from "./settings"; import { setDecorationGridDecoration, setDecorationGridItem } from "./ui/components"; import DecorSection from "./ui/components/DecorSection"; -const { isAnimatedAvatarDecoration } = findByPropsLazy("isAnimatedAvatarDecoration"); export interface AvatarDecoration { asset: string; skuId: string; @@ -61,7 +59,7 @@ export default definePlugin({ }, // Remove NEW label from decor avatar decorations { - match: /(?<=\.Section\.PREMIUM_PURCHASE&&\i)(?<=avatarDecoration:(\i).+?)/, + match: /(?<=\.\i\.PREMIUM_PURCHASE&&\i)(?<=avatarDecoration:(\i).+?)/, replace: "||$1.skuId===$self.SKU_ID" } ] @@ -93,7 +91,7 @@ export default definePlugin({ replacement: [ // Use Decor avatar decoration hook { - match: /(?<=getAvatarDecorationURL\)\({avatarDecoration:)(\i).avatarDecoration(?=,)/, + match: /(?<=\i\)\({avatarDecoration:)(\i).avatarDecoration(?=,)/, replace: "$self.useUserDecorAvatarDecoration($1)??$&" } ] @@ -133,7 +131,7 @@ export default definePlugin({ if (avatarDecoration?.skuId === SKU_ID) { const parts = avatarDecoration.asset.split("_"); // Remove a_ prefix if it's animated and animation is disabled - if (isAnimatedAvatarDecoration(avatarDecoration.asset) && !canAnimate) parts.shift(); + if (avatarDecoration.asset.startsWith("a_") && !canAnimate) parts.shift(); return `${CDN_URL}/${parts.join("_")}.png`; } else if (avatarDecoration?.skuId === RAW_SKU_ID) { return avatarDecoration.asset; diff --git a/src/plugins/disableCallIdle/index.ts b/src/plugins/disableCallIdle/index.ts index d26f7281..c36fce6c 100644 --- a/src/plugins/disableCallIdle/index.ts +++ b/src/plugins/disableCallIdle/index.ts @@ -29,7 +29,7 @@ export default definePlugin({ { find: ".Messages.BOT_CALL_IDLE_DISCONNECT", replacement: { - match: /,?(?=\i\(this,"idleTimeout",new \i\.Timeout\))/, + match: /,?(?=\i\(this,"idleTimeout",new \i\.\i\))/, replace: ";return;" } }, diff --git a/src/plugins/favEmojiFirst/index.ts b/src/plugins/favEmojiFirst/index.ts index afc72a1d..d1a5458d 100644 --- a/src/plugins/favEmojiFirst/index.ts +++ b/src/plugins/favEmojiFirst/index.ts @@ -50,7 +50,7 @@ export default definePlugin({ }, { - find: "MAX_AUTOCOMPLETE_RESULTS+", + find: "numLockedEmojiResults:", replacement: [ // set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10 // and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 5ff61d22..b731899d 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -44,13 +44,8 @@ const pluginsValues = Object.values(Plugins); const settings = Settings.plugins; const forceDisabled = new Set([ - "MessageLogger", "ShowHiddenChannels", - "MoreUserTags", - "Decor", - "IgnoreActivities", - "NoBlockedMessages", - "BetterFolders" + "MoreUserTags" ]); export function isPluginEnabled(p: string) { return ( diff --git a/src/plugins/maskedLinkPaste/index.ts b/src/plugins/maskedLinkPaste/index.ts index dc868992..72931208 100644 --- a/src/plugins/maskedLinkPaste/index.ts +++ b/src/plugins/maskedLinkPaste/index.ts @@ -16,13 +16,15 @@ export default definePlugin({ name: "MaskedLinkPaste", authors: [Devs.TheSun], description: "Pasting a link while having text selected will paste a hyperlink", - patches: [{ - find: ".selection,preventEmojiSurrogates:", - replacement: { - match: /(?<=SlateTransforms.delete.{0,50})(\i)\.insertText\((\i)\)/, - replace: "$self.handlePaste($1, $2, () => $&)" + patches: [ + { + find: ".selection,preventEmojiSurrogates:", + replacement: { + match: /(?<=\i.delete.{0,50})(\i)\.insertText\((\i)\)/, + replace: "$self.handlePaste($1, $2, () => $&)" + } } - }], + ], handlePaste(editor, content: string, originalBehavior: () => void) { if (content && linkRegex.test(content) && editor.operations?.[0]?.type === "remove_text") { diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 427f725c..1ea5b529 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -18,8 +18,10 @@ import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; +import { Message } from "discord-types/general"; const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); @@ -59,6 +61,12 @@ export default definePlugin({ restartNeeded: true, }, }, - isBlocked: message => - RelationshipStore.isBlocked(message.author.id) + + isBlocked(message: Message) { + try { + return RelationshipStore.isBlocked(message.author.id); + } catch (e) { + new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e); + } + } }); diff --git a/src/plugins/noDefaultHangStatus/index.ts b/src/plugins/noDefaultHangStatus/index.ts index 3f77feb2..2245c910 100644 --- a/src/plugins/noDefaultHangStatus/index.ts +++ b/src/plugins/noDefaultHangStatus/index.ts @@ -14,7 +14,7 @@ export default definePlugin({ patches: [ { - find: "HangStatusTypes.CHILLING)", + find: ".CHILLING)", replacement: { match: /{enableHangStatus:(\i),/, replace: "{_enableHangStatus:$1=false," diff --git a/src/plugins/noMosaic/index.ts b/src/plugins/noMosaic/index.ts index 4715bde5..962b90fe 100644 --- a/src/plugins/noMosaic/index.ts +++ b/src/plugins/noMosaic/index.ts @@ -27,7 +27,7 @@ export default definePlugin({ patches: [ { - find: "isGroupableMedia:function()", + find: '=>"IMAGE"===', replacement: { match: /=>"IMAGE"===\i\|\|"VIDEO"===\i;/, replace: "=>false;" diff --git a/src/plugins/openInApp/index.ts b/src/plugins/openInApp/index.ts index 83da5f3c..cb05324a 100644 --- a/src/plugins/openInApp/index.ts +++ b/src/plugins/openInApp/index.ts @@ -63,8 +63,8 @@ export default definePlugin({ { find: "trackAnnouncementMessageLinkClicked({", replacement: { - match: /(?<=handleClick:function\(\)\{return (\i)\}.+?)function \1\(.+?\)\{/, - replace: "async $& if(await $self.handleLink(...arguments)) return;" + match: /function (\i\(\i,\i\)\{)(?=.{0,100}trusted:)/, + replace: "async function $1 if(await $self.handleLink(...arguments)) return;" } }, // Make Spotify profile activity links open in app on web diff --git a/src/plugins/pauseInvitesForever/index.tsx b/src/plugins/pauseInvitesForever/index.tsx index 6a70be1a..332297b6 100644 --- a/src/plugins/pauseInvitesForever/index.tsx +++ b/src/plugins/pauseInvitesForever/index.tsx @@ -19,10 +19,10 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { findByPropsLazy } from "@webpack"; +import { findLazy } from "@webpack"; import { Constants, GuildStore, i18n, RestAPI } from "@webpack/common"; -const { InvitesDisabledExperiment } = findByPropsLazy("InvitesDisabledExperiment"); +const InvitesDisabledExperiment = findLazy(m => m.definition?.id === "2022-07_invites_disabled"); function showDisableInvites(guildId: string) { // Once the experiment is removed, this should keep working @@ -56,7 +56,7 @@ export default definePlugin({ replace: "children: $self.renderInvitesLabel({guildId:arguments[0].guildId,setChecked})", }, { - match: /(\i\.hasDMsDisabled\)\(\i\),\[\i,(\i)\]=\i\.useState\(\i\))/, + match: /(\i\.\i\)\(\i\),\[\i,(\i)\]=\i\.useState\(\i\))/, replace: "$1,setChecked=$2" } ] diff --git a/src/plugins/replyTimestamp/index.tsx b/src/plugins/replyTimestamp/index.tsx index 05ec28b1..851a62b9 100644 --- a/src/plugins/replyTimestamp/index.tsx +++ b/src/plugins/replyTimestamp/index.tsx @@ -9,13 +9,16 @@ import "./style.css"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { findByPropsLazy } from "@webpack"; +import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack"; import { Timestamp } from "@webpack/common"; import type { Message } from "discord-types/general"; import type { HTMLAttributes } from "react"; -const { getMessageTimestampId } = findByPropsLazy("getMessageTimestampId"); -const { calendarFormat, dateFormat, isSameDay } = findByPropsLazy("calendarFormat", "dateFormat", "isSameDay", "accessibilityLabelCalendarFormat"); +const { calendarFormat, dateFormat, isSameDay } = mapMangledModuleLazy("millisecondsInUnit:", { + calendarFormat: filters.byCode("sameElse"), + dateFormat: filters.byCode('":'), + isSameDay: filters.byCode("Math.abs(+"), +}); const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp"); function Sep(props: HTMLAttributes) { @@ -42,7 +45,6 @@ function ReplyTimestamp({ const baseTimestamp = baseMessage.timestamp as any; return ( .{0,15}\((\i),(\i),(\i)\).{0,250}tag:"strong"/, replace: "$&,style:{color:$self.getColor($2?.id,$1)}" }, predicate: () => settings.store.reactorsList, diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index 7ba245da..833904f6 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -48,7 +48,7 @@ export default definePlugin({ authors: [Devs.Rini, Devs.TheKodeToad], patches: [ { - find: ".useCanSeeRemixBadge)", + find: '?"@":"")', replacement: { match: /(?<=onContextMenu:\i,children:).*?\)}/, replace: "$self.renderUsername(arguments[0])}" diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index d9af54c3..fbc75f52 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -58,19 +58,13 @@ export default definePlugin({ patches: [ { find: ".NITRO_BANNER,", - replacement: [ - { - match: /(\i)\.premiumType/, - replace: "$self.patchPremiumType($1)||$&" - }, - { - match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/, - replace: "&&$self.shouldShowBadge(arguments[0])$&" - } - ] + replacement: { + match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/, + replace: "&&$self.shouldShowBadge(arguments[0])$&" + } }, { - find: "BannerLoadingStatus:function", + find: ".banner)==null", replacement: { match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/, replace: "$self.patchBannerUrl(arguments[0])||$&" @@ -115,10 +109,6 @@ export default definePlugin({ if (this.userHasBackground(displayProfile?.userId)) return this.getImageUrl(displayProfile?.userId); }, - patchPremiumType({ userId }: any) { - if (this.userHasBackground(userId)) return 2; - }, - shouldShowBadge({ displayProfile, user }: any) { return displayProfile?.banner && (!this.userHasBackground(user.id) || settings.store.nitroFirst); },