From 5a2c95ae2ac123827b704ed7a8f6b912328f0146 Mon Sep 17 00:00:00 2001 From: Drumm3r <35573506+Drumm3r@users.noreply.github.com> Date: Mon, 24 Jan 2022 11:11:07 +0100 Subject: [PATCH] added initial tapermonkey script and readme --- README.md | 8 ++++++++ tapermonkeyScript.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 README.md create mode 100644 tapermonkeyScript.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..964e0db --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# GatherTownToggle + +A tapermonkey script to toggle microphone and camera with just a key press. + +Press "m" to toggle your microphone. +Press "c" to toggle your camera. + +That's it! diff --git a/tapermonkeyScript.js b/tapermonkeyScript.js new file mode 100644 index 0000000..11e0a2b --- /dev/null +++ b/tapermonkeyScript.js @@ -0,0 +1,38 @@ +// ==UserScript== +// @name gather.town microphone and camera toggle +// @namespace https://schoenenborn.info/ +// @version 1.0.0 +// @description A script which adds the possibility to toggle your camera and microphone with a simple key press +// @author Daniel Schönenborn +// @match https://gather.town/app/* +// @icon https://www.google.com/s2/favicons?domain=gather.town +// @grant none +// ==/UserScript== + +(function () { + 'use strict'; + + document.addEventListener("keydown", function (keydownEvent) { + if (keydownEvent.code === "KeyM") { + let microphoneToggleButton = document.querySelector('[title="Enable microphone"]'); + + if (microphoneToggleButton === null) { + microphoneToggleButton = document.querySelector('[title="Disable microphone"]'); + } + + microphoneToggleButton.click(); + return; + } + + if (keydownEvent.code === "KeyC") { + let cameraToggleButton = document.querySelector('[title="Enable video"]'); + + if (cameraToggleButton === null) { + cameraToggleButton = document.querySelector('[title="Disable video"]'); + } + + cameraToggleButton.click(); + return; + } + }); +})(); \ No newline at end of file