Created
February 6, 2020 14:59
-
-
Save yongzhihuang/ed2960af033e0b66615397cabcf14477 to your computer and use it in GitHub Desktop.
Text to speech Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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