From e584faa1c420182e491599db4d7a0fce876dff63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20M=C3=BCller?= <daniel.q.mueller@stud.h-da.de>
Date: Mon, 28 Jun 2021 14:55:53 +0000
Subject: [PATCH] Improve mute after join

---
 bbb-echotest-autojoin.user.js | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/bbb-echotest-autojoin.user.js b/bbb-echotest-autojoin.user.js
index c89441b..ffd0429 100644
--- a/bbb-echotest-autojoin.user.js
+++ b/bbb-echotest-autojoin.user.js
@@ -1,6 +1,6 @@
 // ==UserScript==
 // @name         BBB Echotest Autojoin
-// @version      0.2
+// @version      0.2.1
 // @website      https://code.fbi.h-da.de/istddmue2/bbb-echotest-autojoin-userscript
 // @downloadURL  https://code.fbi.h-da.de/istddmue2/bbb-echotest-autojoin-userscript/-/raw/master/bbb-echotest-autojoin.user.js
 // @updateURL    https://code.fbi.h-da.de/istddmue2/bbb-echotest-autojoin-userscript/-/raw/master/bbb-echotest-autojoin.user.js
@@ -48,12 +48,16 @@ function isMuted() {
 
         getEchotestAcceptButton().click();
 
-        // Directly after connecting it might be muted for a short time before unmuting
-        await sleep(500);
+        let tStart = new Date();
+
+        // Force mute for 2.5 seconds after joining
+        while (new Date() - tStart < 2500) {
+            // Ensure that the microphone is muted after joining
+            while (isMuted() != true) {
+                getMuteButton()?.click();
+                await sleep(100);
+            }
 
-        // Ensure that the microphone is muted after joining
-        while (isMuted() != true) {
-            getMuteButton().click();
             await sleep(100);
         }
 
@@ -63,4 +67,4 @@ function isMuted() {
 
     }
 
-})();
\ No newline at end of file
+})();
-- 
GitLab