2022-09-01から1ヶ月間の記事一覧
特にいうことはない。 終わり。 なんていうのは、あまりにも笑いのセンスがないので、ちょっと頭をポカリと叩きつつ。 今日はなぜ書いているかというと、書くのに抵抗がないから。 Scrintalを使っていたら、適当にリンクを作っていたら、はてなもやるといい…
特にいうことはない。 終わり。 なんていうのは、あまりにも笑いのセンスがないので、ちょっと頭をポカリと叩きつつ。 今日はなぜ書いているかというと、書くのに抵抗がないから。 Scrintalを使っていたら、適当にリンクを作っていたら、はてなもやるといい…
** 注意
- Web Speech API非対応のブラウザでは音読できません
*/
(function () {
if (!window.speechSynthesis) return;
document.querySelectorAll('article').forEach(function (article) {
var button = document.createElement('button');
button.type = 'button';
button.className = 'btn';
button.textContent = '音読する';
button.style = 'float: right';
article.querySelector('header').appendChild(button);
button.addEventListener('click', function () {
var synth = window.speechSynthesis;
var body = article.querySelector('.entry-content').textContent;
var utter = new SpeechSynthesisUtterance(body);
synth.speak(utter);
});
});
})();