mtslink space2mic

Добавляет на MTS Link возможность включать звук, пока нажата клавиша "Пробел"

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         mtslink space2mic
// @namespace    https://ryzhpolsos.ru/
// @version      0.1
// @description  Добавляет на MTS Link возможность включать звук, пока нажата клавиша "Пробел"
// @author       ryzhpolsos
// @match        https://my.mts-link.ru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mts-link.ru
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(async function(){
    function waitFor(selector){
        return new Promise(res=>{
            let el = document.querySelector(selector);

            if(el){
                res(el);
            }else{
                setTimeout(()=>waitFor(selector).then(e=>res(e)), 100);
            }
        });
    }

    const button = await waitFor('button[data-testid="VCSControlButton.Microfone.Button"]');

    window.addEventListener('keydown', e=>{
        if(e.target.nodeName == 'INPUT' || e.target.nodeName == 'TEXTAREA' || e.target.contentEditable == 'true') return;
        if(e.code == 'Space' && button.querySelector('.icon_mic-off')){
            button.click();
        }
    });

    window.addEventListener('keyup', e=>{
        if(e.target.nodeName == 'INPUT' || e.target.nodeName == 'TEXTAREA' || e.target.contentEditable == 'true') return;
        if(e.code == 'Space' && button.querySelector('.icon_mic-on')){
            button.click();
        }
    });
})();