mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-16 01:53:05 -04:00
feat(plugins): SilentMessageToggle (#586)
Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
parent
253183a16a
commit
bff6788546
4 changed files with 94 additions and 11 deletions
|
@ -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,");
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue