Equicord/src/equicordplugins/fullVcPfp/index.tsx
2026-06-08 08:57:08 -04:00

54 lines
1.8 KiB
TypeScript

/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { disableStyle, enableStyle } from "@api/Styles";
import { EquicordDevs } from "@utils/constants";
import { getUserAvatarUrl } from "@utils/misc";
import definePlugin from "@utils/types";
import { ChannelRTCStore, ChannelStore, UserStore, VoiceStateStore } from "@webpack/common";
import style from "./style.css?managed";
export default definePlugin({
name: "FullVCPFP",
description: "Makes avatars take up the entire vc tile",
tags: ["Appearance", "Voice"],
authors: [EquicordDevs.mochienya],
patches: [
{
find: "\"data-selenium-video-tile\":",
replacement: {
match: /(?<=function\((\i),\i\)\{)/,
replace: "Object.assign($1.style=$1.style||{},$self.getVoiceBackgroundStyles($1));",
}
},
],
getVoiceBackgroundStyles({ className, participantUserId }: { className?: string; participantUserId?: string; }) {
if (!className?.includes("tile") || !participantUserId) return;
const user = UserStore.getUser(participantUserId);
if (!user) return;
const channelId = VoiceStateStore.getVoiceStateForUser(participantUserId)?.channelId;
if (!channelId) return;
const guildId = ChannelStore.getChannel(channelId)?.guild_id;
const isSpeaking = ChannelRTCStore.getSpeakingParticipants(channelId).some(p => p.user.id === participantUserId && p.speaking);
const avatarUrl = getUserAvatarUrl(user, guildId, isSpeaking, 1024);
return {
"--full-res-avatar": `url(${avatarUrl})`
};
},
start() {
enableStyle(style);
},
stop() {
disableStyle(style);
},
});