Google Push to Talk

Hold down the spacebar to unmute the mic in Google Meet; tapping the spacebar toggles mute.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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.
// @match        https://meet.google.com/*
// @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;
        }
    };
})();