|
- var wpm = 200; // Average reading rate in words per minute (WPM)
-
- var ps = document.querySelectorAll('p');
- var wordCount = 0;
- for (var i=0; i<ps.length; i++) {
- wordCount += ps[i].innerText.split(/\s+/).length;
- }
- var $time = document.querySelector('#post-body .dt-published');
- if ($time) {
- $time.style.display = 'inline-block';
- $time.insertAdjacentHTML("afterend", '<span style="color: #666"> · ' + Math.round(wordCount / wpm) + ' min read</span>');
- }
|