From 8208b528c08ea58cefb48a2f90215e471dee0080 Mon Sep 17 00:00:00 2001 From: Inbestigator Date: Sun, 9 Jun 2024 16:12:21 -0700 Subject: [PATCH] Updated regex and added option to use other option by default --- src/plugins/betterBanReasons/index.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/betterBanReasons/index.tsx b/src/plugins/betterBanReasons/index.tsx index 3a997a81a..00eb3088f 100644 --- a/src/plugins/betterBanReasons/index.tsx +++ b/src/plugins/betterBanReasons/index.tsx @@ -77,6 +77,10 @@ const settings = definePluginSettings({ type: OptionType.COMPONENT, component: ReasonsComponent, }, + otherOptionDefault: { + type: OptionType.BOOLEAN, + description: 'Shows a text input instead of a select menu by default. (Equivalent to clicking the "Other" option)' + } }); export default definePlugin({ @@ -86,10 +90,14 @@ export default definePlugin({ patches: [ { find: "default.Messages.BAN_MULTIPLE_CONFIRM_TITLE", - replacement: { - match: /=\[([^\\]*?)\]/, + replacement: [{ + match: /=\[[^]*?\]/, replace: "=$self.getReasons()" - } + }, + { + match: /useState\(0\)/g, + replace: "useState($self.isOtherDefault())" + }] } ], getReasons() { @@ -97,5 +105,8 @@ export default definePlugin({ { name: reason, value: reason } )); }, + isOtherDefault() { + return settings.store.otherOptionDefault ? 1 : 0; + }, settings, });