Action

show reading time

Posted by FlohGro, Last update 12 months ago

created by @FlohGro / more on my Blog

show reading time

displays an alert that shows the reading time of the current draft in minutes and seconds.

[Configuration]

You can change the wpm (words-per-minute) in the script step.
Edit the script step and set the variable wpm in line 13 to your preference.


If you find this useful and want to support me you can donate or buy me a coffe

Buy Me A Coffee

Steps

  • script

    // show reading time
    /*
    Third-grade students = 150 words per minute (wpm)
    Eighth grade students = 250 wpm
    Average college student = 450 wpm
    Average "high-level exec" = 575 wpm
    Average college professor = 675 wpm
    Speed readers = 1,500 wpm
    World speed reading champion = 4,700 wpm
    Average adult = 300 wpm
    */
    
    const wpm = 300;
    
    
    function calcReadingTime(text) {
      const words = text.trim().split(/\s+/).length;
      const decimalMinutes = words / wpm //Math.ceil(words / wpm);
    
    // Extract whole number part 
    const wholeMinutes = Math.floor(decimalMinutes); 
    // Extract decimal part and convert to seconds 
    const decimalPart = decimalMinutes - wholeMinutes; 
    const seconds = Math.round(decimalPart * 60);
    
    
    
      return [words, wholeMinutes + "min " + seconds + "s"];
    }
    
    
    const text = draft.content
    
    let result = calcReadingTime(text);
    const words = result[0]
    const readingTime = result[1]
    
    alert("reading time = " + readingTime + "\n\n" + words + " words, " + wpm + " wpm reading speed")

Options

  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.