Skip to content

Instantly share code, notes, and snippets.

@yongzhihuang
Created February 6, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongzhihuang/ed2960af033e0b66615397cabcf14477 to your computer and use it in GitHub Desktop.
Save yongzhihuang/ed2960af033e0b66615397cabcf14477 to your computer and use it in GitHub Desktop.
Text to speech Slack
// open up chrome console, paste this in
var lastmsg = '';
setInterval(function() {
var newMessage = document.querySelector('.p-message_pane_message__message--last .p-rich_text_section').textContent;
var author = document.querySelector('.p-message_pane_message__message--last .c-message__sender a').text;
console.log(lastmsg !== newMessage, lastmsg, newMessage);
if (lastmsg !== newMessage) {
var msg = new SpeechSynthesisUtterance(`${author} said ${newMessage}`);
window.speechSynthesis.speak(msg);
lastmsg = newMessage;
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment