Plugin

BiggerStreamPreview

This plugin allows you to enlarge stream previews

Media Appearance
index.tsx
Download

Source

src/plugins/biggerStreamPreview/index.tsx
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import { NavContextMenuPatchCallback } from "@api/ContextMenu";
8import { ScreenshareIcon } from "@components/Icons";
9import { Devs } from "@utils/constants";
10import { openImageModal } from "@utils/discord";
11import definePlugin from "@utils/types";
12import { ApplicationStream, Channel, Stream, User } from "@vencord/discord-types";
13import { ApplicationStreamingStore, ApplicationStreamPreviewStore, Menu } from "@webpack/common";
14
15export 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
28export 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
41export 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: 1280
49 });
50};
51
52export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {
53 const stream = ApplicationStreamingStore.getAnyStreamForUser(userId);
54 if (!stream) return;
55
56 const streamPreviewItem = (
57 <Menu.MenuItem
58 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
69export const streamContextPatch: NavContextMenuPatchCallback = (children, { stream }: StreamContextProps) => {
70 return addViewStreamContext(children, { userId: stream.ownerId });
71};
72
73export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {
74 if (user) return addViewStreamContext(children, { userId: user.id });
75};
76
77export 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": streamContextPatch
85 }
86});
87