feat(ViewIcons): Group & User DMs icons support (#2464)
This commit is contained in:
parent
fb19642d8d
commit
cddc811c02
|
@ -36,6 +36,10 @@ interface GuildContextProps {
|
|||
guild?: Guild;
|
||||
}
|
||||
|
||||
interface GroupDMContextProps {
|
||||
channel: Channel;
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
format: {
|
||||
type: OptionType.SELECT,
|
||||
|
@ -145,10 +149,27 @@ const GuildContext: NavContextMenuPatchCallback = (children, { guild }: GuildCon
|
|||
));
|
||||
};
|
||||
|
||||
const GroupDMContext: NavContextMenuPatchCallback = (children, { channel }: GroupDMContextProps) => {
|
||||
if (!channel) return;
|
||||
|
||||
children.splice(-1, 0, (
|
||||
<Menu.MenuGroup>
|
||||
<Menu.MenuItem
|
||||
id="view-group-channel-icon"
|
||||
label="View Icon"
|
||||
action={() =>
|
||||
openImage(IconUtils.getChannelIconURL(channel)!)
|
||||
}
|
||||
icon={ImageIcon}
|
||||
/>
|
||||
</Menu.MenuGroup>
|
||||
));
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "ViewIcons",
|
||||
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz],
|
||||
description: "Makes avatars and banners in user profiles clickable, and adds View Icon/Banner entries in the user and server context menu",
|
||||
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz, Devs.nyx],
|
||||
description: "Makes avatars and banners in user profiles clickable, adds View Icon/Banner entries in the user, server and group channel context menu.",
|
||||
tags: ["ImageUtilities"],
|
||||
|
||||
settings,
|
||||
|
@ -157,11 +178,12 @@ export default definePlugin({
|
|||
|
||||
contextMenus: {
|
||||
"user-context": UserContext,
|
||||
"guild-context": GuildContext
|
||||
"guild-context": GuildContext,
|
||||
"gdm-context": GroupDMContext
|
||||
},
|
||||
|
||||
patches: [
|
||||
// Make pfps clickable
|
||||
// Profiles Modal pfp
|
||||
{
|
||||
find: "User Profile Modal - Context Menu",
|
||||
replacement: {
|
||||
|
@ -169,7 +191,7 @@ export default definePlugin({
|
|||
replace: "{src:$1,onClick:()=>$self.openImage($1)"
|
||||
}
|
||||
},
|
||||
// Make banners clickable
|
||||
// Banners
|
||||
{
|
||||
find: ".NITRO_BANNER,",
|
||||
replacement: {
|
||||
|
@ -180,12 +202,38 @@ export default definePlugin({
|
|||
'onClick:ev=>$1&&ev.target.style.backgroundImage&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
|
||||
}
|
||||
},
|
||||
// User DMs "User Profile" popup in the right
|
||||
{
|
||||
find: ".avatarPositionPanel",
|
||||
replacement: {
|
||||
match: /(?<=avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/,
|
||||
replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}"
|
||||
}
|
||||
},
|
||||
// Group DMs top small & large icon
|
||||
{
|
||||
find: ".recipients.length>=2",
|
||||
all: true,
|
||||
replacement: {
|
||||
match: /null==\i\.icon\?.+?src:(\(0,\i\.getChannelIconURL\).+?\))(?=[,}])/,
|
||||
replace: (m, iconUrl) => `${m},onClick:()=>$self.openImage(${iconUrl})`
|
||||
}
|
||||
},
|
||||
// User DMs top small icon
|
||||
{
|
||||
find: /HiddenVisually,{children:\i\.\i\.Messages\.DIRECT_MESSAGE/,
|
||||
replacement: {
|
||||
match: /.Avatar,.+?src:(.+?\))(?=[,}])/,
|
||||
replace: (m, avatarUrl) => `${m},onClick:()=>$self.openImage(${avatarUrl})`
|
||||
}
|
||||
},
|
||||
// User Dms top large icon
|
||||
{
|
||||
find: 'experimentLocation:"empty_messages"',
|
||||
replacement: {
|
||||
match: /.Avatar,.+?src:(.+?\))(?=[,}])/,
|
||||
replace: (m, avatarUrl) => `${m},onClick:()=>$self.openImage(${avatarUrl})`
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -490,6 +490,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "ScattrdBlade",
|
||||
id: 678007540608532491n
|
||||
},
|
||||
nyx: {
|
||||
name: "verticalsync",
|
||||
id: 328165170536775680n
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
Loading…
Reference in a new issue