Widget for displaying "reading time" on WriteFreely posts.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

13 satır
461 B

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