BetterNotes: Fix patches

This commit is contained in:
Nuckyz 2024-03-22 09:42:19 -03:00
parent ca18b6e044
commit 8d35cc6112
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -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 (
<div className={UserPopoutSectionCssClasses.lastSection}></div>
);