From 2203189a348b28171851824e56b0f42a6596e431 Mon Sep 17 00:00:00 2001
From: Rico040 <93081680+Rico040@users.noreply.github.com>
Date: Mon, 13 May 2024 16:45:50 +1000
Subject: [PATCH] buhh
---
plugins/picture-links/src/index.tsx | 123 ++++++++++++++--------------
1 file changed, 63 insertions(+), 60 deletions(-)
diff --git a/plugins/picture-links/src/index.tsx b/plugins/picture-links/src/index.tsx
index 113c977..03cfcff 100644
--- a/plugins/picture-links/src/index.tsx
+++ b/plugins/picture-links/src/index.tsx
@@ -5,91 +5,94 @@ import { ReactNative } from "@vendetta/metro/common";
const { Pressable } = findByProps("Button", "Text", "View");
const ProfileBanner = findByName("ProfileBanner", false);
const HeaderAvatar = findByName("HeaderAvatar", false);
-const GuildIcon = findByName("GuildIcon", false);
+const GuildIcon = findByName("GuildName", false)
const { openMediaModal } = findByProps("openMediaModal");
const { hideActionSheet } = findByProps("hideActionSheet");
const { getChannelId } = findByStoreName("SelectedChannelStore");
const { getGuildId } = findByStoreName("SelectedGuildStore");
function getImageSize(uri: string): Promise<{width: number, height: number}> {
- return new Promise((resolve, reject) => {
- ReactNative.Image.getSize(
- uri,
- (width, height) => resolve({width, height}),
- (error) => reject(error)
- );
- });
+ return new Promise((resolve, reject) => {
+ ReactNative.Image.getSize(
+ uri,
+ (width, height) => resolve({width, height}),
+ (error) => reject(error)
+ );
+ });
}
async function openModal(src: string, event) {
- const { width, height } = await getImageSize(src);
+ const { width, height } = await getImageSize(src);
- hideActionSheet(); // hide user sheet
- openMediaModal({
- initialSources: [{
- uri: src,
- sourceURI: src,
- width,
- height,
- guildId: getGuildId(),
- channelId: getChannelId(),
- }],
- initialIndex: 0,
- originLayout: {
- width: 0, // this would ideally be the size of the small pfp but this proved very hard to implement
- height: 0,
- x: event.pageX,
- y: event.pageY,
- resizeMode: "fill",
- }
- });
+ hideActionSheet(); // hide user sheet
+ openMediaModal({
+ initialSources: [{
+ uri: src,
+ sourceURI: src,
+ width,
+ height,
+ guildId: getGuildId(),
+ channelId: getChannelId(),
+ }],
+ initialIndex: 0,
+ originLayout: {
+ width: 0, // this would ideally be the size of the small pfp but this proved very hard to implement
+ height: 0,
+ x: event.pageX,
+ y: event.pageY,
+ resizeMode: "fill",
+ }
+ });
}
const unpatchAvatar = after("default", HeaderAvatar, ([{ user, style, guildId }], res) => {
- const guildSpecific = user.guildMemberAvatars?.[guildId] && `https://cdn.discordapp.com/guilds/${guildId}/users/${user.id}/avatars/${user.guildMemberAvatars[guildId]}.png?size=4096`;
- const image = user?.getAvatarURL?.(false, 4096, true);
- if (!image) return res;
+ const guildSpecific = user.guildMemberAvatars?.[guildId] && `https://cdn.discordapp.com/guilds/${guildId}/users/${user.id}/avatars/${user.guildMemberAvatars[guildId]}.png?size=4096`;
+ const image = user?.getAvatarURL?.(false, 4096, true);
+ if (!image) return res;
- const url =
- typeof image === "number"
- ? `https://cdn.discordapp.com/embed/avatars/${Number(BigInt(user.id) >> 22n) % 6}.png`
- : image?.replace(".webp", ".png");
+ const url =
+ typeof image === "number"
+ ? `https://cdn.discordapp.com/embed/avatars/${Number(BigInt(user.id) >> 22n) % 6}.png`
+ : image?.replace(".webp", ".png");
- delete res.props.style;
+ delete res.props.style;
- return (
- openModal(url, nativeEvent)}
- onLongPress={({ nativeEvent }) => guildSpecific && openModal(guildSpecific, nativeEvent)}
- style={style}>
- {res}
-
- );
+ return (
+ openModal(url, nativeEvent)}
+ onLongPress={({ nativeEvent }) => guildSpecific && openModal(guildSpecific, nativeEvent)}
+ style={style}>
+ {res}
+
+ );
});
const unpatchBanner = after("default", ProfileBanner, ([{ bannerSource }], res) => {
- if (typeof bannerSource?.uri !== "string" || !res) return res;
+ if (typeof bannerSource?.uri !== "string" || !res) return res;
- const url = bannerSource.uri
- .replace(/(?:\?size=\d{3,4})?$/, "?size=4096")
- .replace(".webp", ".png");
+ const url = bannerSource.uri
+ .replace(/(?:\?size=\d{3,4})?$/, "?size=4096")
+ .replace(".webp", ".png");
- return openModal(url, nativeEvent)}>{res};
+ return openModal(url, nativeEvent)}>{res};
});
-const unpatchGuildIcon = after("default", GuildIcon, ([{ size, guild }], res) => {
- if (size !== "XLARGE") return;
- const url = `https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.png?size=4096`
+var unpatchGuildIcon = after("default", GuildIcon, ([{ size, guild }], res) => {
+ if (size !== "XLARGE") return;
+ var ext = "png"
+ if (guild?.icon.includes('a_')) { ext = "gif"; }
+ const url = `https://cdn.discordapp.com/icons/${guild?.id}/${guild?.icon}.${ext}?size=4096`
- return (
- openModal(url, nativeEvent)}>
- {res}
-
- );
+ return (
+ openModal(url, nativeEvent)}>
+ {res}
+
+ );
});
+
export function onUnload() {
- unpatchAvatar();
- unpatchBanner();
- unpatchGuildIcon();
+ unpatchAvatar();
+ unpatchBanner();
+ unpatchGuildIcon();
}
\ No newline at end of file