From bff67885461a60ddd533b1dcec353efb66d4f1a0 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 8 Mar 2023 21:19:28 -0300 Subject: feat(plugins): SilentMessageToggle (#586) Co-authored-by: Ven --- src/plugins/apiContextMenu.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/plugins/apiContextMenu.ts') diff --git a/src/plugins/apiContextMenu.ts b/src/plugins/apiContextMenu.ts index 69dfde4..1874f5f 100644 --- a/src/plugins/apiContextMenu.ts +++ b/src/plugins/apiContextMenu.ts @@ -38,13 +38,11 @@ function listener(exports: any, id: number) { noWarn: true, find: "navId:", replacement: [{ - /** Regex explanation - * Use of https://blog.stevenlevithan.com/archives/mimic-atomic-groups to mimick atomic groups: (?=(...))\1 - * Match ${id} and look behind it for the first match of `=`: ${id}(?=(\i)=.+?) - * Match rest of the code until it finds `.${key},{`: .+?\2\.${key},{ - */ - match: RegExp(`(?=(${id}(?<=(\\i)=.+?).+?\\2\\.${key},{))\\1`, "g"), - replace: "$&contextMenuApiArguments:arguments," + match: RegExp(`${id}(?<=(\\i)=.+?).+$`), + replace: (code, varName) => { + const regex = RegExp(`${key},{(?<=${varName}\\.${key},{)`, "g"); + return code.replace(regex, "$&contextMenuApiArguments:arguments,"); + } }] }); -- cgit