Equicord/src/equicordplugins/fullVcPfp/index.tsx
2026-04-16 13:45:58 -04:00

53 lines
1.7 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 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 = user.getAvatarURL(guildId, 1024, isSpeaking);
return {
"--full-res-avatar": `url(${avatarUrl})`
};
},
start() {
enableStyle(style);
},
stop() {
disableStyle(style);
},
});