Badges: Fix custom badges being turned into orbs

This commit is contained in:
Nuckyz 2025-02-25 16:29:27 -03:00
parent 4e32126e5d
commit 8d0f312122
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
3 changed files with 26 additions and 16 deletions

View file

@ -73,19 +73,17 @@ export default definePlugin({
find: ".description,delay:",
replacement: [
{
// alt: "", aria-hidden: false, src: originalSrc
match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/,
// ...badge.props, ..., src: badge.image ?? ...
replace: "...$1.props,$& $1.image??"
match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/,
replace: (_, rest, originalSrc, badge) => `...${badge}.props,${rest}${badge}.image??(${originalSrc})`
},
{
match: /(?<="aria-label":(\i)\.description,.{0,200})children:/,
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
replace: "children:$1.component?$self.renderBadgeComponent({...$1}) :"
},
// conditionally override their onClick with badge.onClick if it exists
{
match: /href:(\i)\.link/,
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
replace: "...($1.onClick&&{onClick:vcE=>$1.onClick(vcE,$1)}),$&"
}
]
}