Last active
June 5, 2017 14:59
-
-
Save crakaC/2cabbb9369622d386449e93b2bc95c0f to your computer and use it in GitHub Desktop.
マストドンのローカルタイムラインを読み上げるやつ
This file contains 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
var ids = new Set(); | |
var observer = new MutationObserver((ms) => { | |
ms.forEach((m) => { | |
m.addedNodes.forEach((n) => { | |
if(n.className != "status") return; | |
var id = n.querySelector('.status__relative-time').href.split('/').pop(); | |
var id_int = parseInt(id); | |
if(ids.has(id_int)){ | |
return; | |
} | |
ids.add(id_int); | |
var t = n.querySelector('.status__content>p').textContent.replace(/https?:\/\/[\x21-\x7e]+/gi, '').replace(/[wwWW]+/, '、ワラ'); | |
if(t.length > 35){ | |
t = t.substr(0, 35) + "以下略"; | |
} | |
var s = new SpeechSynthesisUtterance(t); | |
s.rate = 1.2; | |
s.lang = 'ja-JP'; | |
speechSynthesis.speak( s ); | |
}); | |
}) | |
}); | |
observer.observe(document.querySelectorAll(".status-list")[0], {childList: true});//[1]でLTL |
新着だけ読み上げるようにした
Google Chrome 58.0.3029.110 (64-bit), macOS Sierra 10.12.5でのみ動作確認済み
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
35文字以降は以下略