Last active
October 9, 2022 14:38
-
-
Save woxtu/6b214ea9cef53e246beb9fc31c5295fe to your computer and use it in GitHub Desktop.
Qiitadon 新着 読み上げ ブックマークレット
This file contains hidden or 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
(() => { | |
ws = new WebSocket("wss://streaming.qiitadon.com:4000/api/v1/streaming/?stream=public:local"); | |
ws.addEventListener("message", (ev) => { | |
const { event, payload } = JSON.parse(ev.data); | |
if (event === "update") { | |
const status = JSON.parse(payload); | |
speechSynthesis.cancel(); | |
speechSynthesis.speak(new SpeechSynthesisUtterance(status.account.display_name || status.account.username)); | |
speechSynthesis.speak(new SpeechSynthesisUtterance(status.content.replace(/<\/?[^>]+(>|$)/g, ""))); | |
} | |
}); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/woxtu/b8e200d7062979307588acc79be2101c