aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/apiContextMenu.ts
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2023-03-08 21:19:28 -0300
committerGitHub <noreply@github.com>2023-03-09 01:19:28 +0100
commitbff67885461a60ddd533b1dcec353efb66d4f1a0 (patch)
tree7785fda5085f44a97ed58af56b025e65a220a227 /src/plugins/apiContextMenu.ts
parent253183a16a78ce0ebc183af7e078b61eb0d4d758 (diff)
downloadVencord-bff67885461a60ddd533b1dcec353efb66d4f1a0.tar.gz
Vencord-bff67885461a60ddd533b1dcec353efb66d4f1a0.tar.bz2
Vencord-bff67885461a60ddd533b1dcec353efb66d4f1a0.zip
feat(plugins): SilentMessageToggle (#586)
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/apiContextMenu.ts')
-rw-r--r--src/plugins/apiContextMenu.ts12
1 files changed, 5 insertions, 7 deletions
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 `<variable name>=`: ${id}(?=(\i)=.+?)
- * Match rest of the code until it finds `<variable name>.${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,");
+ }
}]
});