Last active
June 15, 2020 07:32
-
-
Save marcreynolds/6c629eaf8bfe87986ebe90ebea7daf85 to your computer and use it in GitHub Desktop.
Google Meet/Hangouts Push-to-Talk
This file contains hidden or 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 Push to Talk | |
// @namespace http://tampermonkey.net/ | |
// @version 0.5 | |
// @description Hold down the spacebar to unmute the mic in Google Meet; tapping the spacebar toggles mute. | |
// @author Marc Reynolds (github.com/marcreynolds) | |
// @match https://meet.google.com/* | |
// @updateUrl https://gist.github.com/marcreynolds/6c629eaf8bfe87986ebe90ebea7daf85/raw/google-meet-spacebar.user.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window._getGoogleMeetMuteEl = function() { | |
if(window._googleMeetMuteEl === undefined) { | |
window._googleMeetMuteEl = document.querySelector('div[role=\"button\"][data-tooltip*=\"microphone\"]'); | |
} | |
return window._googleMeetMuteEl; | |
}; | |
window._clickMute = function() { | |
window._getGoogleMeetMuteEl().click(); | |
}; | |
window._isMuted = function() { | |
return window._getGoogleMeetMuteEl().attributes["data-tooltip"].value.match(/turn on microphone/i) !== null; | |
}; | |
document.body.onkeyup = function(e) { | |
if(e.keyCode == 32){ | |
e.stopPropagation(); | |
e.preventDefault(); | |
window._clickMute(); | |
window._meetupSpaceDown = false; | |
} | |
}; | |
document.body.onkeydown = function(e) { | |
if(e.keyCode == 32 && window._meetupSpaceDown !== true){ | |
e.stopPropagation(); | |
e.preventDefault(); | |
if(window._isMuted()) { | |
window._clickMute(); | |
} | |
window._meetupSpaceDown = true; | |
} | |
}; | |
})(); |
Feel free to save yourself the time in answering this question. Found an extension here
@qwertynik, thanks for the heads-up on the extension!
@marcreynolds
You're welcome!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I create an extension out of this? Of course with credits to you. Or if you already have an extension can you share the link?