Word Count: Difference between revisions

From Librivox wiki
Jump to navigationJump to search
Content deleted Content added
Peegee (talk | contribs)
New page: == Firefox Add-on == A useful add-on is Word Count Plus, which counts the number of words in selected text. It can also add the count to a running total. [[https://addons.mozilla.org/en-US...
 
Peegee (talk | contribs)
No edit summary
Line 1: Line 1:
== Firefox Add-on ==
== Word Counts ==
A useful add-on is Word Count Plus, which counts the number of words in selected text. It can also add the count to a running total. [[https://addons.mozilla.org/en-US/firefox/addon/4718 https://addons.mozilla.org/en-US/firefox/addon/4718]]


LibriVox member ''peegee'' has written a script for web browsers which may make the BC's job of compiling word counts for the Magic Window a little easier.
== Alternative for Firefox, Chrome and Opera ==

LibriVox member ''peegee'' has written a script for web browsers which may make the job a little easier.
== How it Works ==


The script runs against the HTML ebooks on Gutenberg.
The script runs against the HTML ebooks on Gutenberg.
Line 16: Line 16:
Here are a few screenshots to illustrate the process:
Here are a few screenshots to illustrate the process:


[[Image:Wordcount1.png|frame|The first prompt]]
[[Image:Wordcount1.png|thumb|left|351x223px|The first prompt]]
[[Image:Wordcount2.png|frame|The choice]]
[[Image:Wordcount2.png|thumb|left|351x223px|Choose target number]]
[[Image:Wordcount3.png|frame|The count displayed]]
[[Image:Wordcount3.png|thumb|left|351x223px|The count displayed]]


<br clear="all" />
== Installing the Script ==
== Installing the Script ==

The method of installation depends on the browser
The method of installation depends on the browser (Firefox and Chrome may need to be re-started after installation, Opera does not):


=== Firefox ===
=== Firefox ===


You will first need the GreaseMonkey add-on for Firefox which is available here :
# You will first need the GreaseMonkey add-on for Firefox which is available here :
[[https://addons.mozilla.org/en-US/firefox/addon/748 Greasemonkey]]
[[https://addons.mozilla.org/en-US/firefox/addon/748 Greasemonkey]]
# Once you have GreaseMonkey installed, go here to and click on the '''Install''' button

Once you have GreaseMonkey installed, go here to and click on the '''Install''' button
[[http://userscripts.org/scripts/show/69969 Firefox Install]]
[[http://userscripts.org/scripts/show/69969 Firefox Install]]


Line 35: Line 36:
Just go here to install the Chrome version and click on the '''Install''' button (GreaseMonkey not needed)
Just go here to install the Chrome version and click on the '''Install''' button (GreaseMonkey not needed)
[[http://userscripts.org/scripts/show/70234 Chrome Install]]
[[http://userscripts.org/scripts/show/70234 Chrome Install]]



=== Opera ===
=== Opera ===

# To enable User JavaScript, use Tools > Preferences > Advanced > Content > JavaScript options, and select the directory where you will put your User JavaScript files (probably best if its a new folder with nothing else in it).
# then go to the script http://userscripts.org/scripts/show/70234
# click the Install button to get the script in a new tab in Opera.
# from the menu click File > Save As to save it into the folder you chose in the first step (probably best to just keep the suggested file-name - whatever name you choose it MUST end in .user.js )

== Limitations ==

The script only works on the Gutenberg online HTML books, not the ''text'' or ''zipped HTML'', or other formats.

== Support ==

If you have any problems installing or using this script you can either post a message in this forum thread [[http://librivox.org/forum/viewtopic.php?t=24437 forum topic]] or send a Private Message to ''peegee''.

== Other Alternatives ==

=== Firefox Add-on ===

A useful alternative is the ''Word Count Plus'' add-on for Firefox, which counts the number of words in selected text. It can also add the count to a running total. [[https://addons.mozilla.org/en-US/firefox/addon/4718 https://addons.mozilla.org/en-US/firefox/addon/4718]]

=== Opera Bookmarklet ===

Creating a new bookmark, with the code below, will count the words in a highlighted piece of text.

You can use ''Word Count'' for the bookmark name, and then put the code into the address box, in the ''details'' section.

javascript:(function(){var t;if (window.getSelection) t = window.getSelection();else if (document.selection) t = document.selection.createRange();if (t.text != undefined) t = t.text;if(!t || t == ""){ a = document.getElementsByTagName("textarea"); for(i=0; i<a.length; i++) { if(a[i].selectionStart != undefined && a[i].selectionStart != a[i].selectionEnd) { t = a[i].value.substring(a[i].selectionStart, a[i].selectionEnd); break; } }}if(!t || t == "")alert("please select some text");else alert("word count: " + t.toString().match(/(\S+)/g).length);})()

Revision as of 15:26, 18 April 2010

Word Counts

LibriVox member peegee has written a script for web browsers which may make the BC's job of compiling word counts for the Magic Window a little easier.

How it Works

The script runs against the HTML ebooks on Gutenberg.

  1. you click the paragraph where you want to start the count,
  2. it asks you the target number of words,
  3. it quickly goes through every paragraph from that point onwards and counts the words and the running total
  4. it stops when it reaches the target, or the end of the chapter if before
  5. the page is temporarily changed to display the word counts right there at the end of each paragraph
  6. you can repeat this as many times as you like, each time you click a paragraph the temporary page changes are removed

Screenshots

Here are a few screenshots to illustrate the process:

The first prompt
Choose target number
The count displayed


Installing the Script

The method of installation depends on the browser (Firefox and Chrome may need to be re-started after installation, Opera does not):

Firefox

  1. You will first need the GreaseMonkey add-on for Firefox which is available here :

[Greasemonkey]

  1. Once you have GreaseMonkey installed, go here to and click on the Install button

[Firefox Install]

Google Chrome

Just go here to install the Chrome version and click on the Install button (GreaseMonkey not needed) [Chrome Install]

Opera

  1. To enable User JavaScript, use Tools > Preferences > Advanced > Content > JavaScript options, and select the directory where you will put your User JavaScript files (probably best if its a new folder with nothing else in it).
  2. then go to the script http://userscripts.org/scripts/show/70234
  3. click the Install button to get the script in a new tab in Opera.
  4. from the menu click File > Save As to save it into the folder you chose in the first step (probably best to just keep the suggested file-name - whatever name you choose it MUST end in .user.js )

Limitations

The script only works on the Gutenberg online HTML books, not the text or zipped HTML, or other formats.

Support

If you have any problems installing or using this script you can either post a message in this forum thread [forum topic] or send a Private Message to peegee.

Other Alternatives

Firefox Add-on

A useful alternative is the Word Count Plus add-on for Firefox, which counts the number of words in selected text. It can also add the count to a running total. [https://addons.mozilla.org/en-US/firefox/addon/4718]

Opera Bookmarklet

Creating a new bookmark, with the code below, will count the words in a highlighted piece of text.

You can use Word Count for the bookmark name, and then put the code into the address box, in the details section.

javascript:(function(){var t;if (window.getSelection) t = window.getSelection();else if (document.selection) t = document.selection.createRange();if (t.text != undefined) t = t.text;if(!t || t == ""){ a = document.getElementsByTagName("textarea"); for(i=0; i<a.length; i++) { if(a[i].selectionStart != undefined && a[i].selectionStart != a[i].selectionEnd) { t = a[i].value.substring(a[i].selectionStart, a[i].selectionEnd); break; } }}if(!t || t == "")alert("please select some text");else alert("word count: " + t.toString().match(/(\S+)/g).length);})()