feat: hide venmic from input devices, switch devices modal
This commit is contained in:
parent
01883c40a5
commit
96927b14e9
3 changed files with 33 additions and 3 deletions
23
src/renderer/patches/hideSwitchDevice.tsx
Normal file
23
src/renderer/patches/hideSwitchDevice.tsx
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0
|
||||||
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||||
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { addPatch } from "./shared";
|
||||||
|
|
||||||
|
addPatch({
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "lastOutputSystemDevice.justChanged",
|
||||||
|
replacement: {
|
||||||
|
match: /((\w)\.default\.getState\(\).neverShowModal)/,
|
||||||
|
replace: "$1 || $self.shouldIgnore($2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
shouldIgnore(state: any) {
|
||||||
|
return Object.keys(state?.default?.lastDeviceConnected)?.[0] === "vencord-screen-share";
|
||||||
|
}
|
||||||
|
});
|
|
@ -7,6 +7,7 @@
|
||||||
// TODO: Possibly auto generate glob if we have more patches in the future
|
// TODO: Possibly auto generate glob if we have more patches in the future
|
||||||
import "./enableNotificationsByDefault";
|
import "./enableNotificationsByDefault";
|
||||||
import "./platformClass";
|
import "./platformClass";
|
||||||
|
import "./hideSwitchDevice";
|
||||||
import "./screenShareAudio";
|
import "./screenShareAudio";
|
||||||
import "./spellCheck";
|
import "./spellCheck";
|
||||||
import "./windowsTitleBar";
|
import "./windowsTitleBar";
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
import { isLinux } from "renderer/utils";
|
import { isLinux } from "renderer/utils";
|
||||||
|
|
||||||
if (isLinux) {
|
if (isLinux) {
|
||||||
const original = navigator.mediaDevices.getDisplayMedia;
|
const originalMedia = navigator.mediaDevices.getDisplayMedia;
|
||||||
|
const originalDevices = navigator.mediaDevices.enumerateDevices;
|
||||||
|
|
||||||
async function getVirtmic() {
|
async function getVirtmic() {
|
||||||
try {
|
try {
|
||||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
const devices = await originalDevices();
|
||||||
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
|
const audioDevice = devices.find(({ label }) => label === "vencord-screen-share");
|
||||||
return audioDevice?.deviceId;
|
return audioDevice?.deviceId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -19,8 +20,13 @@ if (isLinux) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navigator.mediaDevices.enumerateDevices = async function () {
|
||||||
|
const result = await originalDevices.call(this);
|
||||||
|
return result.filter(x => x.label !== "vencord-screen-share");
|
||||||
|
};
|
||||||
|
|
||||||
navigator.mediaDevices.getDisplayMedia = async function (opts) {
|
navigator.mediaDevices.getDisplayMedia = async function (opts) {
|
||||||
const stream = await original.call(this, opts);
|
const stream = await originalMedia.call(this, opts);
|
||||||
const id = await getVirtmic();
|
const id = await getVirtmic();
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
|
|
Loading…
Reference in a new issue