From 098da8c3fd95cdd1f299b86d0b919b001009a1df Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:26:13 -0300 Subject: [PATCH] Fix ViewIcons --- src/plugins/viewIcons/index.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index fd6b7b6bf..ccbc8ddca 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -65,7 +65,9 @@ const settings = definePluginSettings({ } }); -function openImage(url: string) { +function openImage(url?: string) { + if (!url) return; + const format = url.startsWith("/") ? "png" : settings.store.format; const u = new URL(url, window.location.href); @@ -171,12 +173,12 @@ export default definePlugin({ }, patches: [ - // Make pfps clickable + // Make pfps clickable and add pointer cursor { - find: "onAddFriend:function", + find: ".AVATAR_DECORATION_STATUS_ROUND_16;", replacement: { - match: /\{src:(\i)(?=,avatarDecoration)/, - replace: "{src:$1,onClick:()=>$self.openImage($1)" + match: /memo\(.{0,50}(?=let{statusColor:\i,status:\i,...\i}=(\i),)/, + replace: (m, props) => `${m}${props}.onClick=()=>$self.openImage(${props}.src);${props}.style={cursor:${props}.src?"pointer":void 0};` } }, // Make banners clickable