Greasy Fork 支持简体中文。

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.

  1. // ==UserScript==
  2. // @name Speech Synthesis for MonkeyType
  3. // @namespace http://github.com/mefengl
  4. // @version 0.0.2
  5. // @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.
  6. // @author mefengl
  7. // @match https://monkeytype.com/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=monkeytype.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. let lastSpoken = '';
  17.  
  18. const targetNode = document.getElementById('words');
  19.  
  20. const pollElement = () => {
  21. const text = targetNode.innerText.replace(/\n/g, ' ');
  22. if (text !== lastSpoken) {
  23. if (lastSpoken !== '') {
  24. speechSynthesis.cancel();
  25. }
  26. lastSpoken = text;
  27. let utterance = new SpeechSynthesisUtterance(text);
  28. utterance.rate = 0.8;
  29. speechSynthesis.speak(utterance);
  30. }
  31. };
  32.  
  33. setInterval(pollElement, 500);
  34. })();