better intl transforming

This commit is contained in:
Nuckyz 2024-11-03 16:23:30 -03:00
parent e4aba774e0
commit 39de683b6e
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
8 changed files with 11 additions and 11 deletions

View file

@ -32,9 +32,9 @@ export default definePlugin({
} }
}, },
{ {
find: '#{intl::SERVERS}"]),children', find: "#{intl::SERVERS}),children",
replacement: { 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($&)" replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
} }
} }

View file

@ -149,7 +149,7 @@ export default definePlugin({
patches: [{ patches: [{
find: "#{intl::BEGINNING_DM}", find: "#{intl::BEGINNING_DM}",
replacement: { replacement: {
match: /#{intl::BEGINNING_DM}"\],{.+?}\),(?=.{0,300}(\i)\.isMultiUserDM)/, match: /#{intl::BEGINNING_DM},{.+?}\),(?=.{0,300}(\i)\.isMultiUserDM)/,
replace: "$& $self.renderContributorDmWarningCard({ channel: $1 })," replace: "$& $self.renderContributorDmWarningCard({ channel: $1 }),"
} }
}], }],

View file

@ -41,7 +41,7 @@ export default definePlugin({
{ {
find: "DefaultCustomizationSections", find: "DefaultCustomizationSections",
replacement: { replacement: {
match: /(?<=#{intl::USER_SETTINGS_AVATAR_DECORATION}"\]\)},"decoration"\),)/, match: /(?<=#{intl::USER_SETTINGS_AVATAR_DECORATION}\)},"decoration"\),)/,
replace: "$self.DecorSection()," replace: "$self.DecorSection(),"
} }
}, },

View file

@ -128,7 +128,7 @@ export default definePlugin({
{ {
find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}", find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}",
replacement: { 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})" replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})"
} }
} }

View file

@ -50,7 +50,7 @@ export default definePlugin({
{ {
find: "#{intl::FRIENDS_SECTION_ONLINE}", find: "#{intl::FRIENDS_SECTION_ONLINE}",
replacement: { replacement: {
match: /(\(0,\i\.jsx\)\(\i\.TabBar\.Item,\{id:\i\.\i)\.BLOCKED,className:([^\s]+?)\.item,children:\i\.\i\.string\(\i\.\i#{intl::BLOCKED}"\]\)\}\)/, match: /(\(0,\i\.jsx\)\(\i\.TabBar\.Item,\{id:\i\.\i)\.BLOCKED,className:([^\s]+?)\.item,children:\i\.\i\.string\(\i\.\i#{intl::BLOCKED}\)\}\)/,
replace: "$1.IMPLICIT,className:$2.item,children:\"Implicit\"}),$&" replace: "$1.IMPLICIT,className:$2.item,children:\"Implicit\"}),$&"
}, },
}, },

View file

@ -192,7 +192,7 @@ export default definePlugin({
replacement: [ replacement: [
// make the tag show the right text // make the tag show the right text
{ {
match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=(.{0,40}#{intl::APP_TAG}"\]\))/, match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=(.{0,40}#{intl::APP_TAG}\))/,
replace: (_, origSwitch, variant, tags, displayedText, originalText) => replace: (_, origSwitch, variant, tags, displayedText, originalText) =>
`${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}],${originalText})}` `${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}],${originalText})}`
}, },

View file

@ -39,7 +39,7 @@ export default definePlugin({
{ {
find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}", find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}",
replacement: { replacement: {
match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}"\]\)/, match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}\)/,
replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])" replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])"
} }
}, },

View file

@ -25,12 +25,12 @@ export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
const hashed = runtimeHashMessageKey(key); const hashed = runtimeHashMessageKey(key);
const isString = typeof match === "string"; const isString = typeof match === "string";
const hasSpecialChars = /^[\d]/.test(hashed) || !/^[\w$]+$/.test(hashed); const hasSpecialChars = !Number.isNaN(Number(hashed[0])) || hashed.includes("+");
if (hasSpecialChars) { if (hasSpecialChars) {
return isString return isString
? `["${hashed}` ? `["${hashed}"]`
: String.raw`(?:\["${hashed})`.replaceAll("+", "\\+"); : String.raw`(?:\["${hashed}"\])`.replaceAll("+", "\\+");
} }
return isString ? `.${hashed}` : String.raw`(?:\.${hashed})`; return isString ? `.${hashed}` : String.raw`(?:\.${hashed})`;