From 8d35cc6112a4e50250e397d40c315c9d841e8666 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:42:19 -0300 Subject: [PATCH] BetterNotes: Fix patches --- src/plugins/betterNotes/index.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/betterNotes/index.tsx b/src/plugins/betterNotes/index.tsx index da41b973..2183d98e 100644 --- a/src/plugins/betterNotes/index.tsx +++ b/src/plugins/betterNotes/index.tsx @@ -18,6 +18,7 @@ import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; +import { canonicalizeMatch } from "@utils/patches"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -39,8 +40,12 @@ export default definePlugin({ match: /hideNote:.+?(?=([,}].*?\)))/g, replace: (m, rest) => { const destructuringMatch = rest.match(/}=.+/); - if (destructuringMatch == null) return "hideNote:!0"; - return m; + if (destructuringMatch) { + const defaultValueMatch = m.match(canonicalizeMatch(/hideNote:(\i)=!?\d/)); + return defaultValueMatch ? `hideNote:${defaultValueMatch[1]}=!0` : m; + } + + return "hideNote:!0"; } } }, @@ -52,10 +57,10 @@ export default definePlugin({ } }, { - find: ".Messages.NOTE}", + find: ".popularApplicationCommandIds,", replacement: { - match: /(?<=return \i\?)null(?=:\(0,\i\.jsxs)/, - replace: "$self.patchPadding(arguments[0])" + match: /lastSection:(!?\i)}\),/, + replace: "$&$self.patchPadding($1)," } } ], @@ -75,8 +80,8 @@ export default definePlugin({ } }, - patchPadding(e: any) { - if (!e.lastSection) return; + patchPadding(lastSection: any) { + if (!lastSection) return; return (
);