From 46980fd8bbf391cb87dc27f2b32d07b22c1d4245 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 11 Dec 2020 18:35:24 -0500 Subject: [PATCH] Add readtime.js widget This script displays a "read time" on WriteFreely post pages. It appends the time next to the date on the post. --- readtime.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 readtime.js diff --git a/readtime.js b/readtime.js new file mode 100644 index 0000000..a74f93b --- /dev/null +++ b/readtime.js @@ -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 · ' + Math.round(wordCount / wpm) + ' min read');