mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-09 14:43:03 -04:00
ScreenshareKeybind
This commit is contained in:
parent
078eba2f02
commit
dbcc34289e
6 changed files with 92 additions and 10 deletions
|
@ -130,6 +130,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
||||||
- ReplyPingControl by ant0n & MrDiamond
|
- ReplyPingControl by ant0n & MrDiamond
|
||||||
- RPCEditor by Nyako & nin0dev
|
- RPCEditor by Nyako & nin0dev
|
||||||
- RPCStats by Samwich
|
- RPCStats by Samwich
|
||||||
|
- ScreenshareKeybind by HAHALOSAH
|
||||||
- SearchFix by Jaxx
|
- SearchFix by Jaxx
|
||||||
- SekaiStickers by MaiKokain
|
- SekaiStickers by MaiKokain
|
||||||
- ServerSearch by camila314
|
- ServerSearch by camila314
|
||||||
|
@ -139,6 +140,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
||||||
- Slap by Korbo
|
- Slap by Korbo
|
||||||
- SoundBoardLogger by Moxxie, fres, echo, maintained by thororen
|
- SoundBoardLogger by Moxxie, fres, echo, maintained by thororen
|
||||||
- SpotifyLyrics by Joona
|
- SpotifyLyrics by Joona
|
||||||
|
- StatsfmPresence by Crxa
|
||||||
- StatusPresets by iamme
|
- StatusPresets by iamme
|
||||||
- SteamStatusSync by niko
|
- SteamStatusSync by niko
|
||||||
- StickerBlocker by Samwich
|
- StickerBlocker by Samwich
|
||||||
|
|
90
src/equicordplugins/screenshareKeybind/index.tsx
Normal file
90
src/equicordplugins/screenshareKeybind/index.tsx
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -24,7 +24,6 @@ import {
|
||||||
UserStore,
|
UserStore,
|
||||||
} from "@webpack/common";
|
} from "@webpack/common";
|
||||||
|
|
||||||
// /
|
|
||||||
// Create an in-memory cache (temporary, lost on restart)
|
// Create an in-memory cache (temporary, lost on restart)
|
||||||
const ttsCache = new Map<string, string>();
|
const ttsCache = new Map<string, string>();
|
||||||
|
|
||||||
|
@ -68,7 +67,6 @@ async function setCachedVoiceInDB(cacheKey: string, blob: Blob): Promise<void> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// /
|
|
||||||
interface VoiceState {
|
interface VoiceState {
|
||||||
userId: string;
|
userId: string;
|
||||||
channelId?: 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
|
// 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
|
// not say the second mute, which would lead you to believe they're unmuted
|
||||||
|
|
||||||
// /
|
|
||||||
async function speak(text: string) {
|
async function speak(text: string) {
|
||||||
if (text.trim().length === 0) return;
|
if (text.trim().length === 0) return;
|
||||||
|
|
||||||
|
@ -169,7 +166,6 @@ async function speak(text: string) {
|
||||||
audio.play();
|
audio.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /
|
|
||||||
function clean(str: string) {
|
function clean(str: string) {
|
||||||
const replacer = settings.store.latinOnly
|
const replacer = settings.store.latinOnly
|
||||||
? /[^\p{Script=Latin}\p{Number}\p{Punctuation}\s]/gu
|
? /[^\p{Script=Latin}\p{Number}\p{Punctuation}\s]/gu
|
||||||
|
|
|
@ -190,8 +190,6 @@ function isTimestampDisabled() {
|
||||||
return settings.store.timestampMode !== TimestampMode.CUSTOM;
|
return settings.store.timestampMode !== TimestampMode.CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function onlineFriendCount(): number {
|
function onlineFriendCount(): number {
|
||||||
let onlineFriends = 0;
|
let onlineFriends = 0;
|
||||||
const relationships = RelationshipStore.getRelationships();
|
const relationships = RelationshipStore.getRelationships();
|
||||||
|
@ -333,8 +331,6 @@ async function createActivity(): Promise<Activity | undefined> {
|
||||||
state = "";
|
state = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
const activity: Activity = {
|
const activity: Activity = {
|
||||||
application_id: appID || "0",
|
application_id: appID || "0",
|
||||||
name: appName,
|
name: appName,
|
||||||
|
|
|
@ -212,8 +212,6 @@ export function getTargetString(urlStr: string) {
|
||||||
return url.href;
|
return url.href;
|
||||||
case "path":
|
case "path":
|
||||||
if (url.host === "media.discordapp.net" || url.host === "tenor.com")
|
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.split("/").at(-1) ?? url.pathname;
|
||||||
return url.pathname;
|
return url.pathname;
|
||||||
case "hostandpath":
|
case "hostandpath":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue