Skip to content

Instantly share code, notes, and snippets.

@iamandrewluca
Last active September 18, 2022 05:01
Show Gist options
  • Save iamandrewluca/2b7b4d76df729c55e35f642a710f7f6b to your computer and use it in GitHub Desktop.
Save iamandrewluca/2b7b4d76df729c55e35f642a710f7f6b to your computer and use it in GitHub Desktop.
Will speak any select text from page #bookmarklet
javascript: void ((async () => {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
let interval = 500;
const intervalId = setInterval(() => {
interval += 500;
if (interval > 5000) { return; }
if (window.speechSynthesis.getVoices().length !== 0) {
clearInterval(intervalId);
const text = window.getSelection().toString();
const utterance = new SpeechSynthesisUtterance(text);
speechSynthesis.speak(utterance);
}
}, interval);
})());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment