|
|
@@ -0,0 +1,10 @@ |
|
|
|
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'); |
|
|
|
$time.style.display = 'inline-block'; |
|
|
|
$time.insertAdjacentHTML("afterend", '<span class="dt-published"> · ' + Math.round(wordCount / wpm) + ' min read</span>'); |