diff --git a/README.md b/README.md index d2e150bf..578b2d1a 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - ReplyPingControl by ant0n & MrDiamond - RPCEditor by Nyako & nin0dev - RPCStats by Samwich +- ScreenshareKeybind by HAHALOSAH - SearchFix by Jaxx - SekaiStickers by MaiKokain - ServerSearch by camila314 @@ -139,6 +140,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - Slap by Korbo - SoundBoardLogger by Moxxie, fres, echo, maintained by thororen - SpotifyLyrics by Joona +- StatsfmPresence by Crxa - StatusPresets by iamme - SteamStatusSync by niko - StickerBlocker by Samwich diff --git a/src/equicordplugins/screenshareKeybind/index.tsx b/src/equicordplugins/screenshareKeybind/index.tsx new file mode 100644 index 00000000..534a6cb6 --- /dev/null +++ b/src/equicordplugins/screenshareKeybind/index.tsx @@ -0,0 +1,90 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2025 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByCode, findByProps } from "@webpack"; +import { ChannelStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { VoiceState } from "@webpack/types"; + +const settings = definePluginSettings({ + instantScreenShare: { + description: "Instantly screenshare screen 1 when joining a voice channel", + type: OptionType.BOOLEAN, + default: false + } +}); + +let hasStreamed = false; + +async function startStream() { + const startStream = findByCode('type:"STREAM_START"'); + const mediaEngine = findByProps("getMediaEngine").getMediaEngine(); + const getDesktopSources = findByCode("desktop sources"); + const selected = SelectedChannelStore.getVoiceChannelId(); + if (!selected) return; + const channel = ChannelStore.getChannel(selected); + const sources = await getDesktopSources(mediaEngine, ["screen"], null); + if (!sources || sources.length === 0) return; + const source = sources[0]; + startStream(channel.guild_id, selected, { + "pid": null, + "sourceId": source.id, + "sourceName": source.name, + "audioSourceId": null, + "sound": true, + "previewDisabled": false + }); +} + +export default definePlugin({ + name: "ScreenshareKeybind", + description: "Adds a keybind to instantly screenshare your first screen", + authors: [Devs.HAHALOSAH], + settings, + patches: [ + { + find: "DISCONNECT_FROM_VOICE_CHANNEL]", + replacement: { + match: /\[\i\.\i\.DISCONNECT_FROM_VOICE_CHANNEL/, + replace: "SHARE_ENTIRE_SCREEN:{onTrigger:$self.trigger,keyEvents:{keyUp:!1,keyDown:!0}},$&" + }, + }, + { + find: "keybindActionTypes()", + replacement: { + match: /=\[(\{value:\i\.\i\.UNASSIGNED)/, + replace: "=[{value:'SHARE_ENTIRE_SCREEN',label:'Share Entire Screen'},$1" + } + } + ], + flux: { + async VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) { + if (!settings.store.instantScreenShare) return; + const myId = UserStore.getCurrentUser().id; + for (const state of voiceStates) { + const { userId, channelId } = state; + if (userId !== myId) continue; + + if (channelId && !hasStreamed) { + hasStreamed = true; + await startStream(); + } + + if (!channelId) { + hasStreamed = false; + } + + break; + } + } + }, + async trigger() { + await startStream(); + } +}); + diff --git a/src/plugins/Statsfm/index.tsx b/src/equicordplugins/statsfmPresence/index.tsx similarity index 100% rename from src/plugins/Statsfm/index.tsx rename to src/equicordplugins/statsfmPresence/index.tsx diff --git a/src/equicordplugins/vcNarratorCustom/index.tsx b/src/equicordplugins/vcNarratorCustom/index.tsx index fb28e884..3c38abe8 100644 --- a/src/equicordplugins/vcNarratorCustom/index.tsx +++ b/src/equicordplugins/vcNarratorCustom/index.tsx @@ -24,7 +24,6 @@ import { UserStore, } from "@webpack/common"; -// / // Create an in-memory cache (temporary, lost on restart) const ttsCache = new Map(); @@ -68,7 +67,6 @@ async function setCachedVoiceInDB(cacheKey: string, blob: Blob): Promise { }); } -// / interface VoiceState { userId: string; channelId?: string; @@ -88,7 +86,6 @@ const VoiceStateStore = findByPropsLazy( // Filtering out events is not as simple as just dropping duplicates, as otherwise mute, unmute, mute would // not say the second mute, which would lead you to believe they're unmuted -// / async function speak(text: string) { if (text.trim().length === 0) return; @@ -169,7 +166,6 @@ async function speak(text: string) { audio.play(); } -// / function clean(str: string) { const replacer = settings.store.latinOnly ? /[^\p{Script=Latin}\p{Number}\p{Punctuation}\s]/gu diff --git a/src/equicordplugins/vencordRPC/index.ts b/src/equicordplugins/vencordRPC/index.ts index e0e2f13f..d1900df0 100644 --- a/src/equicordplugins/vencordRPC/index.ts +++ b/src/equicordplugins/vencordRPC/index.ts @@ -190,8 +190,6 @@ function isTimestampDisabled() { return settings.store.timestampMode !== TimestampMode.CUSTOM; } -// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - function onlineFriendCount(): number { let onlineFriends = 0; const relationships = RelationshipStore.getRelationships(); @@ -333,8 +331,6 @@ async function createActivity(): Promise { state = ""; } - // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const activity: Activity = { application_id: appID || "0", name: appName, diff --git a/src/plugins/favGifSearch/index.tsx b/src/plugins/favGifSearch/index.tsx index 04ea3f59..80f7117e 100644 --- a/src/plugins/favGifSearch/index.tsx +++ b/src/plugins/favGifSearch/index.tsx @@ -212,8 +212,6 @@ export function getTargetString(urlStr: string) { return url.href; case "path": if (url.host === "media.discordapp.net" || url.host === "tenor.com") - // /attachments/899763415290097664/1095711736461537381/attachment-1.gif -> attachment-1.gif - // /view/some-gif-hi-24248063 -> some-gif-hi-24248063 return url.pathname.split("/").at(-1) ?? url.pathname; return url.pathname; case "hostandpath":