From 68473d04d8b4851c790157cd3482c9270fa19886 Mon Sep 17 00:00:00 2001 From: Kacper Herchel Date: Tue, 25 Oct 2022 17:01:10 +0200 Subject: [PATCH] Fix mute and deafen keybinds disconnecting from the call instead of performing their appropriate action --- assets/userscript.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/assets/userscript.js b/assets/userscript.js index cf00169..88d33e8 100644 --- a/assets/userscript.js +++ b/assets/userscript.js @@ -183,14 +183,21 @@ setInterval(() => { el.appendChild(div); } - const muteBtn = document.getElementsByClassName( + const buttonContainer = document.getElementsByClassName("container-YkUktl")[0]; + if (!buttonContainer) { + console.log('dsa: Cannot locate Mute/Deafen/Settings button container, please report this on GitHub'); + } + + const muteBtn = buttonContainer ? buttonContainer.getElementsByClassName( "button-12Fmur enabled-9OeuTA button-f2h6uQ lookBlank-21BCro colorBrand-I6CyqQ grow-2sR_-F" - )[0]; - window.discordScreenaudioToggleMute = () => muteBtn.click(); - const deafenBtn = document.getElementsByClassName( + )[0] : null; + window.discordScreenaudioToggleMute = () => muteBtn && muteBtn.click(); + + const deafenBtn = buttonContainer ? buttonContainer.getElementsByClassName( "button-12Fmur enabled-9OeuTA button-f2h6uQ lookBlank-21BCro colorBrand-I6CyqQ grow-2sR_-F" - )[1]; - window.discordScreenaudioToggleDeafen = () => deafenBtn.click(); + )[1] : null; + + window.discordScreenaudioToggleDeafen = () => deafenBtn && deafenBtn.click(); if (window.discordScreenaudioResolutionString) { for (const el of document.getElementsByClassName(