Greasy Fork is available in English.

mtslink space2mic

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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