非公開 記事本文自動読み上げツール

    @@ -8,8 +8,7 @@ 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); - + .reduce((max, elm) => Array.from(elm.children).filter(c=>c.tagName === 'P').reduce((n, p)=> n + p.textContent.length, 0) > Array.from(max.children).filter(c=>c.tagName === 'P').reduce((n, p)=> n + p.textContent.length, 0) ? elm : max); let utterance = new SpeechSynthesisUtterance(elm.textContent.trim()); utterance.lang='ja'; speechSynthesis.speak(utterance);
  • /*
     * @title 記事本文自動読み上げツール
     * @description <p>タグの多い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').reduce((n, p)=> n + p.textContent.length, 0) > Array.from(max.children).filter(c=>c.tagName === 'P').reduce((n, p)=> n + p.textContent.length, 0) ? elm : max);
    let utterance = new SpeechSynthesisUtterance(elm.textContent.trim());
    utterance.lang='ja';
    speechSynthesis.speak(utterance);
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2022/09/10 18:13:06 - 2022-09-10
  2. 2022/09/01 00:51:51 - 2022-09-01
  3. 2022/06/25 21:58:26 - 2022-06-25
  4. 2022/06/25 21:56:30 - 2022-06-25
  5. 2022/06/25 21:54:12 - 2022-06-25
  6. 2022/06/24 14:48:10 - 2022-06-24
  7. 2022/06/24 14:28:38 - 2022-06-24
  8. 2022/06/24 02:58:45 - 2022-06-24