aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorKode <TheKodeToad@proton.me>2023-04-13 03:25:38 +0100
committerGitHub <noreply@github.com>2023-04-13 04:25:38 +0200
commit71849cac9a6313432cd9976cb5de4ce060e74b0e (patch)
treef37cbb32aace2d9227eda9034b21929b33c8eae9 /src/plugins
parente34da54271ed8027d337a484f0ec00749c71a53b (diff)
downloadVencord-71849cac9a6313432cd9976cb5de4ce060e74b0e.tar.gz
Vencord-71849cac9a6313432cd9976cb5de4ce060e74b0e.tar.bz2
Vencord-71849cac9a6313432cd9976cb5de4ce060e74b0e.zip
Fix ViewIcons on webhooks and default avatars! (#880)
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Co-authored-by: Vendicated <vendicated@riseup.net>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/viewIcons.tsx23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx
index cff4fe6..85105c5 100644
--- a/src/plugins/viewIcons.tsx
+++ b/src/plugins/viewIcons.tsx
@@ -63,9 +63,10 @@ const settings = definePluginSettings({
});
function openImage(url: string) {
- const u = new URL(url);
+ const format = url.startsWith("/") ? "png" : settings.store.format;
+ const u = new URL(url, window.location.href);
u.searchParams.set("size", "512");
- u.pathname = u.pathname.replace(/\.(png|jpe?g|webp)$/, `.${settings.store.format}`);
+ u.pathname = u.pathname.replace(/\.(png|jpe?g|webp)$/, `.${format}`);
url = u.toString();
openModal(modalProps => (
@@ -148,8 +149,8 @@ const GuildContext: NavContextMenuPatchCallback = (children, { guild: { id, icon
export default definePlugin({
name: "ViewIcons",
- authors: [Devs.Ven],
- description: "Makes Avatars/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],
+ description: "Makes avatars and banners in user profiles clickable, and adds View Icon/Banner entries in the user and server context menu",
settings,
@@ -171,15 +172,21 @@ export default definePlugin({
replacement: {
// global because Discord has two components that are 99% identical with one small change ._.
match: /\{src:(\i),avatarDecoration/g,
- replace: (_, src) => `{src:${src},onClick:()=>$self.openImage(${src}),avatarDecoration`
+ replace: "{src:$1,onClick:()=>$self.openImage($1),avatarDecoration"
}
}, {
find: ".popoutNoBannerPremium",
replacement: {
match: /style:.{0,10}\{\},(\i)\)/,
- replace: (m, style) =>
- `onClick:${style}.backgroundImage&&(${style}.cursor="pointer",` +
- `()=>$self.openImage(${style}.backgroundImage.replace("url(", ""))),${m}`
+ replace:
+ "onClick:$1.backgroundImage&&($1.cursor=\"pointer\"," +
+ "()=>$self.openImage($1.backgroundImage.replace(\"url(\", \"\"))),$&"
+ }
+ }, {
+ find: "().avatarWrapperNonUserBot",
+ replacement: {
+ match: /(avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/,
+ replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}"
}
}
]