diff --git a/src/plugins/_api/serverList.ts b/src/plugins/_api/serverList.ts index 400126c7..01ace3a1 100644 --- a/src/plugins/_api/serverList.ts +++ b/src/plugins/_api/serverList.ts @@ -32,10 +32,10 @@ export default definePlugin({ } }, { - find: "Messages.SERVERS,children", + find: '#{intl::SERVERS}"]),children', replacement: [ { - match: /(?<=Messages\.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 85843f63..c9605c74 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/decor/index.tsx b/src/plugins/decor/index.tsx index 4236043f..00816758 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 3929e813..d62ab328 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..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/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"; diff --git a/src/utils/patches.ts b/src/utils/patches.ts index 855432cc..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") {