mtslink space2mic

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
        }
    });
})();