Skip to content

Instantly share code, notes, and snippets.

@ampcpmgp
Last active October 31, 2024 01:27
Show Gist options
  • Save ampcpmgp/a765d7137c4b140f5885c58e0f0b9a4b to your computer and use it in GitHub Desktop.
Save ampcpmgp/a765d7137c4b140f5885c58e0f0b9a4b to your computer and use it in GitHub Desktop.
定期的に指定メッセージを発言するブックマークレット
start()
function start() {
const message = window.prompt("発言してほしいメッセージを入力してください")
const intervalMinutes = window.prompt("何分に1回発言してほしいか入力してください", "60") - 0
const intervalMilliseconds = intervalMinutes * 60 * 1
document.title = "🌸定期発言中!"
speak(message)
setInterval(() => {
speak(message)
}, intervalMinutes * 60 * 1000)
}
function speak(message) {
const synth = window.speechSynthesis;
const utterThis = new SpeechSynthesisUtterance(message);
synth.speak(utterThis);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment