ViewIcons: Fix viewing banners

This commit is contained in:
Vendicated 2023-04-28 18:36:22 +02:00
parent 0fe0fecba2
commit 1b2cb52dac
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905

View file

@ -167,26 +167,30 @@ export default definePlugin({
}, },
patches: [ patches: [
// Make pfps clickable
{ {
find: "onAddFriend:", find: "onAddFriend:",
replacement: { replacement: {
// global because Discord has two components that are 99% identical with one small change ._. match: /\{src:(\i)(?=,avatarDecoration)/,
match: /\{src:(\i),avatarDecoration/g, replace: "{src:$1,onClick:()=>$self.openImage($1)"
replace: "{src:$1,onClick:()=>$self.openImage($1),avatarDecoration"
} }
}, { },
find: ".popoutNoBannerPremium", // Make banners clickable
{
find: ".NITRO_BANNER,",
replacement: { replacement: {
match: /style:.{0,10}\{\},(\i)\)/, // style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl,
match: /style:\{(?=backgroundImage:(\i&&\i)\?"url\("\.concat\((\i),)/,
replace: replace:
"onClick:$1.backgroundImage&&($1.cursor=\"pointer\"," + // onClick: () => shouldShowBanner && openImage(bannerUrl), style: { cursor: shouldShowBanner ? "pointer" : void 0,
"()=>$self.openImage($1.backgroundImage.replace(\"url(\", \"\"))),$&" 'onClick:()=>$1&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
} }
}, { },
{
find: "().avatarWrapperNonUserBot", find: "().avatarWrapperNonUserBot",
replacement: { replacement: {
match: /(avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/, match: /(?<=avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/,
replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}"
} }
} }
] ]