Last active
March 9, 2021 19:33
-
-
Save MikeRawding/de001c0c37e9fb550cb53107c93f4b27 to your computer and use it in GitHub Desktop.
Tampermonkey script to add PTT to google meet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google Meet Spacebar PTT | |
// @namespace https://github.com/mikerawding | |
// @version 0.1 | |
// @description Use Spacebar as Push-To-Talk for Google Meet | |
// @author Mike Rawding | |
// @match https://meet.google.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const hotKey = 'Space' | |
let hotKeyDown = false | |
const toggleMute = () => { | |
document.dispatchEvent( | |
new KeyboardEvent("keydown", { | |
key: "d", | |
keyCode: 68, | |
code: "KeyD", | |
which: 68, | |
ctrlKey: true, | |
}) | |
) | |
} | |
window.addEventListener('keydown', event => { | |
if (event.code === hotKey && document.querySelector('[data-is-muted="true"]') && !hotKeyDown) { | |
hotKeyDown = true | |
toggleMute() | |
} | |
}) | |
window.addEventListener('keyup', event => { | |
if (event.code === hotKey && document.querySelector('[data-is-muted="false"]')) { | |
hotKeyDown = false | |
toggleMute() | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Done, thanks.