From d099aff45a370aea867fb7607e8e3907cb426bac Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 3 Nov 2024 13:58:43 -0300 Subject: [PATCH 1/3] and more --- src/plugins/_core/supportHelper.tsx | 2 +- src/plugins/fakeProfileThemes/index.tsx | 2 +- src/plugins/moreUserTags/index.tsx | 2 +- src/plugins/validReply/index.ts | 2 +- src/utils/index.ts | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index 32647509..f76773b3 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -149,7 +149,7 @@ export default definePlugin({ patches: [{ find: "#{intl::BEGINNING_DM}", replacement: { - match: /BEGINNING_DM\.format\(\{.+?\}\),(?=.{0,300}(\i)\.isMultiUserDM)/, + match: /#{intl::BEGINNING_DM}"],{.+?}\),(?=.{0,300}(\i)\.isMultiUserDM)/, replace: "$& $self.renderContributorDmWarningCard({ channel: $1 })," } }], diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx index d546650b..b1cce725 100644 --- a/src/plugins/fakeProfileThemes/index.tsx +++ b/src/plugins/fakeProfileThemes/index.tsx @@ -128,7 +128,7 @@ export default definePlugin({ { find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}", replacement: { - match: /RESET_PROFILE_THEME}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/, + match: /#{intl::USER_SETTINGS_RESET_PROFILE_THEME}\)}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/, replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})" } } diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 119d02c3..c6695d31 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -232,7 +232,7 @@ export default definePlugin({ } }, { - find: "#{ìntl::USER_PROFILE_PRONOUNS}", + find: "#{intl::USER_PROFILE_PRONOUNS}", replacement: { match: /(?=,hideBotTag:!0)/, replace: ",moreTags_channelId:arguments[0].moreTags_channelId" diff --git a/src/plugins/validReply/index.ts b/src/plugins/validReply/index.ts index 989513d0..5e9f8bed 100644 --- a/src/plugins/validReply/index.ts +++ b/src/plugins/validReply/index.ts @@ -39,7 +39,7 @@ export default definePlugin({ { find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}", replacement: { - match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}\)/, + match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}"]\)/, replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])" } }, diff --git a/src/utils/index.ts b/src/utils/index.ts index 62f3f6e9..ed347fdc 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,6 +22,7 @@ export * from "./ChangeList"; export * from "./constants"; export * from "./discord"; export * from "./guards"; +export * from "./intlHash"; export * from "./lazy"; export * from "./lazyReact"; export * from "./localStorage"; From e0098deaab5c8a07801c3822ac24a02e0b47ee0e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:01:56 -0300 Subject: [PATCH 2/3] lets work alright? --- src/utils/patches.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/patches.ts b/src/utils/patches.ts index 855432cc..5411ff37 100644 --- a/src/utils/patches.ts +++ b/src/utils/patches.ts @@ -26,7 +26,7 @@ export function canonicalizeMatch(match: T): T { const isStr = typeof match === "string"; return /^[\d]/.test(hashed) || !/^[\w$]+$/.test(hashed) - ? isStr ? `["${hashed}` : String.raw`(?:\["${hashed}"\])` + ? isStr ? `["${hashed}` : String.raw`(?:\["${hashed})` : isStr ? `.${hashed}` : String.raw`(?:\.${hashed})`; }); From 3cf79ec436c608de09ea3f47c50f0ff120567d31 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:17:35 -0300 Subject: [PATCH 3/3] Fix most patches --- src/plugins/_api/serverList.ts | 2 +- src/plugins/_core/supportHelper.tsx | 2 +- src/plugins/decor/index.tsx | 2 +- src/plugins/fakeProfileThemes/index.tsx | 2 +- src/plugins/validReply/index.ts | 2 +- src/utils/patches.ts | 14 ++++++++++---- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/plugins/_api/serverList.ts b/src/plugins/_api/serverList.ts index 38bcfd90..15a1389f 100644 --- a/src/plugins/_api/serverList.ts +++ b/src/plugins/_api/serverList.ts @@ -34,7 +34,7 @@ export default definePlugin({ { find: '#{intl::SERVERS}"]),children', replacement: { - match: /(?<=#{intl::SERVERS}\),children:)\i\.map\(\i\)/, + match: /(?<=#{intl::SERVERS}"\]\),children:)\i\.map\(\i\)/, replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)" } } diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index f76773b3..6be41d31 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -149,7 +149,7 @@ export default definePlugin({ patches: [{ find: "#{intl::BEGINNING_DM}", replacement: { - match: /#{intl::BEGINNING_DM}"],{.+?}\),(?=.{0,300}(\i)\.isMultiUserDM)/, + match: /#{intl::BEGINNING_DM}"\],{.+?}\),(?=.{0,300}(\i)\.isMultiUserDM)/, replace: "$& $self.renderContributorDmWarningCard({ channel: $1 })," } }], diff --git a/src/plugins/decor/index.tsx b/src/plugins/decor/index.tsx index 69a7a1a5..47207922 100644 --- a/src/plugins/decor/index.tsx +++ b/src/plugins/decor/index.tsx @@ -41,7 +41,7 @@ export default definePlugin({ { find: "DefaultCustomizationSections", replacement: { - match: /(?<=#{intl::USER_SETTINGS_AVATAR_DECORATION}\)},"decoration"\),)/, + match: /(?<=#{intl::USER_SETTINGS_AVATAR_DECORATION}"\]\)},"decoration"\),)/, replace: "$self.DecorSection()," } }, diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx index b1cce725..edc0e740 100644 --- a/src/plugins/fakeProfileThemes/index.tsx +++ b/src/plugins/fakeProfileThemes/index.tsx @@ -128,7 +128,7 @@ export default definePlugin({ { find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}", replacement: { - match: /#{intl::USER_SETTINGS_RESET_PROFILE_THEME}\)}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/, + match: /#{intl::USER_SETTINGS_RESET_PROFILE_THEME}"\]\)}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/, replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})" } } diff --git a/src/plugins/validReply/index.ts b/src/plugins/validReply/index.ts index 5e9f8bed..4b62f790 100644 --- a/src/plugins/validReply/index.ts +++ b/src/plugins/validReply/index.ts @@ -39,7 +39,7 @@ export default definePlugin({ { find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}", replacement: { - match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}"]\)/, + match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}"\]\)/, replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])" } }, diff --git a/src/utils/patches.ts b/src/utils/patches.ts index 5411ff37..17c541b6 100644 --- a/src/utils/patches.ts +++ b/src/utils/patches.ts @@ -23,11 +23,17 @@ export function canonicalizeMatch(match: T): T { let partialCanon = typeof match === "string" ? match : match.source; partialCanon = partialCanon.replaceAll(/#{intl::([A-Za-z_$][\w$]*)}/g, (_, key) => { const hashed = runtimeHashMessageKey(key); - const isStr = typeof match === "string"; - return /^[\d]/.test(hashed) || !/^[\w$]+$/.test(hashed) - ? isStr ? `["${hashed}` : String.raw`(?:\["${hashed})` - : isStr ? `.${hashed}` : String.raw`(?:\.${hashed})`; + const isString = typeof match === "string"; + const hasSpecialChars = /^[\d]/.test(hashed) || !/^[\w$]+$/.test(hashed); + + if (hasSpecialChars) { + return isString + ? `["${hashed}` + : String.raw`(?:\["${hashed})`.replaceAll("+", "\\+"); + } + + return isString ? `.${hashed}` : String.raw`(?:\.${hashed})`; }); if (typeof match === "string") {