// ==UserScript== // @name 記事本文自動読み上げツール // @description
タグの多いDIV要素を探して https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API で読み上げます // @include http://* // ==/UserScript== /* * @title 記事本文自動読み上げツール * @description
タグの多いDIV要素を探して https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API で読み上げます * @include http://* * @license MIT License * @require */ let elm = Array.from(document.querySelectorAll('div')) .filter(elm => elm.children.length>0) .reduce((max, elm) => Array.from(elm.children).filter(c=>c.tagName === 'P').length > Array.from(max.children).filter(c=>c.tagName === 'P').length ? elm : max); let utterance = new SpeechSynthesisUtterance(elm.textContent.trim()); utterance.lang='ja'; speechSynthesis.speak(utterance);