Speech Synthesis for MonkeyType

A userscript that uses speech synthesis to read out the words on monkeytype.com. This is helpful for improving typing speed while listening to the words.

Versione datata 21/05/2023. Vedi la nuova versione l'ultima versione.

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         Speech Synthesis for MonkeyType
// @namespace    http://github.com/mefengl
// @version      0.0.1
// @description  A userscript that uses speech synthesis to read out the words on monkeytype.com. This is helpful for improving typing speed while listening to the words.
// @author       mefengl
// @match        https://monkeytype.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=monkeytype.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let lastSpoken = '';

    const targetNode = document.getElementById('words');

    const pollElement = () => {
        const text = targetNode.innerText.replace(/\n/g, ' ');
        if (text !== lastSpoken) {
            if (lastSpoken !== '') {
                speechSynthesis.cancel();
            }
            lastSpoken = text;
            let utterance = new SpeechSynthesisUtterance(text);
            utterance.rate = 0.2;
            speechSynthesis.speak(utterance);
        }
    };

    setInterval(pollElement, 500);
})();