Plugin
BiggerStreamPreview
This plugin allows you to enlarge stream previews
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { NavContextMenuPatchCallback } from "@api/ContextMenu";8
import { ScreenshareIcon } from "@components/Icons";9
import { Devs } from "@utils/constants";10
import { openImageModal } from "@utils/discord";11
import definePlugin from "@utils/types";12
import { ApplicationStream, Channel, Stream, User } from "@vencord/discord-types";13
import { ApplicationStreamingStore, ApplicationStreamPreviewStore, Menu } from "@webpack/common";14
15
export interface UserContextProps {16
channel: Channel,17
channelSelected: boolean,18
className: string,19
config: { context: string; };20
context: string,21
onHeightUpdate: Function,22
position: string,23
target: HTMLElement,24
theme: string,25
user: User;26
}27
28
export interface StreamContextProps {29
appContext: string,30
className: string,31
config: { context: string; };32
context: string,33
exitFullscreen: Function,34
onHeightUpdate: Function,35
position: string,36
target: HTMLElement,37
stream: Stream,38
theme: string,39
}40
41
export const handleViewPreview = async ({ guildId, channelId, ownerId }: ApplicationStream | Stream) => {42
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);43
if (!previewUrl) return;44
45
openImageModal({46
url: previewUrl,47
height: 720,48
width: 128049
});50
};51
52
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {53
const stream = ApplicationStreamingStore.getAnyStreamForUser(userId);54
if (!stream) return;55
56
const streamPreviewItem = (57
<Menu.MenuItem58
label="View Stream Preview"59
id="view-stream-preview"60
icon={ScreenshareIcon}61
action={() => stream && handleViewPreview(stream)}62
disabled={!stream}63
/>64
);65
66
children.push(<Menu.MenuSeparator />, streamPreviewItem);67
};68
69
export const streamContextPatch: NavContextMenuPatchCallback = (children, { stream }: StreamContextProps) => {70
return addViewStreamContext(children, { userId: stream.ownerId });71
};72
73
export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {74
if (user) return addViewStreamContext(children, { userId: user.id });75
};76
77
export default definePlugin({78
name: "BiggerStreamPreview",79
description: "This plugin allows you to enlarge stream previews",80
tags: ["Media", "Appearance"],81
authors: [Devs.phil],82
contextMenus: {83
"user-context": userContextPatch,84
"stream-context": streamContextPatch85
}86
});87