feat(ViewIcons): Group & User DMs icons support (#2464)
This commit is contained in:
parent
fb19642d8d
commit
cddc811c02
2 changed files with 57 additions and 5 deletions
|
@ -36,6 +36,10 @@ interface GuildContextProps {
|
||||||
guild?: Guild;
|
guild?: Guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface GroupDMContextProps {
|
||||||
|
channel: Channel;
|
||||||
|
}
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
format: {
|
format: {
|
||||||
type: OptionType.SELECT,
|
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({
|
export default definePlugin({
|
||||||
name: "ViewIcons",
|
name: "ViewIcons",
|
||||||
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz],
|
authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz, Devs.nyx],
|
||||||
description: "Makes avatars and banners in user profiles clickable, and adds View Icon/Banner entries in the user and server context menu",
|
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"],
|
tags: ["ImageUtilities"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
@ -157,11 +178,12 @@ export default definePlugin({
|
||||||
|
|
||||||
contextMenus: {
|
contextMenus: {
|
||||||
"user-context": UserContext,
|
"user-context": UserContext,
|
||||||
"guild-context": GuildContext
|
"guild-context": GuildContext,
|
||||||
|
"gdm-context": GroupDMContext
|
||||||
},
|
},
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
// Make pfps clickable
|
// Profiles Modal pfp
|
||||||
{
|
{
|
||||||
find: "User Profile Modal - Context Menu",
|
find: "User Profile Modal - Context Menu",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -169,7 +191,7 @@ export default definePlugin({
|
||||||
replace: "{src:$1,onClick:()=>$self.openImage($1)"
|
replace: "{src:$1,onClick:()=>$self.openImage($1)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Make banners clickable
|
// Banners
|
||||||
{
|
{
|
||||||
find: ".NITRO_BANNER,",
|
find: ".NITRO_BANNER,",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -180,12 +202,38 @@ export default definePlugin({
|
||||||
'onClick:ev=>$1&&ev.target.style.backgroundImage&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
|
'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",
|
find: ".avatarPositionPanel",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/,
|
match: /(?<=avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/,
|
||||||
replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}"
|
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",
|
name: "ScattrdBlade",
|
||||||
id: 678007540608532491n
|
id: 678007540608532491n
|
||||||
},
|
},
|
||||||
|
nyx: {
|
||||||
|
name: "verticalsync",
|
||||||
|
id: 328165170536775680n
|
||||||
|
},
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
Loading…
Reference in a new issue