Scripts by filiptammergard

Text analyzer script

I made a little script for getting number of characters, words and estimated reading time of currently selected text. Much easier than copying something into a text editor to see these things.

https://user-images.githubusercontent.com/44197016/114854865-8f2b8e00-9de5-11eb-9308-050d9f865575.mov

// Menu: Analyze Text
// Description: Select a text and see data about it
// Author: Filip Tammergård
// Twitter: @filipang
// Shortcut: cmd opt shift control t
const { countCharacters, countWords, getReadingTime } = await npm(
"text-analyzer"
);
const { getSelectedText } = await kit("text");
const selectedText = await getSelectedText();
const characters = countCharacters(selectedText);
const words = countWords(selectedText);
const readingTime = getReadingTime(selectedText);
const readingTimeMinutes = readingTime.minutes;
show(`
<section style="margin:10px">
<p>Characters: ${characters}</p>
<p>Words: ${words}</p>
<p>Reading time: ${readingTimeMinutes} minutes</p>
</section>
`);

Could be extended a lot!

Is it possible to set the size of the window that pops up with show?

Discuss Post