Bookmarklet to clean Sparknotes for printing

Apparently I can’t buy the pdf-versions of the stuff on, because I don’t have an american home address? That makes me grumpy. I guess I can just print out the articles myself, though that’s not very convenient.

But OK. To create a nice printable Sparknote page (without the mess, just the text), I use the following javascript code. It extracts the div element that has the className of studyGuideText and removes everything else (including all style sheets and an advert, floatingad).

javascript: ( function() {

var body = document.getElementsByTagName('body')[0];
var divs = body.getElementsByTagName('div');
var text = null;
for(var i=0; i<divs.length; i++){
	if(divs[i].className=='studyGuideText') {
		text = divs[i];
if (text == null) {
	alert('Did not find any text to extract (looking for divs of class studyGuideText)');
while (body.hasChildNodes()){


var els=document.getElementsByTagName('*');


The bookmarklet version — all in one line etc:


Tested only with Firefox (Gecko) and Epiphany (Webkit). (I would have liked to just publish it as a link, but WordPress mangles it to something incomprehensible.)


Order of mp3-tracks in Sansa Clip+

I use a Sansa Clip+ mp3-player for listening to audiobooks. It took me quite a while to understand how to get the player to play the tracks in the correct order, but I think the following should do it.

One has to edit the mp3-tags (metadata embedded into the mp3-files). I use EasyTAG to do this (which is available for Ubuntu, and probably many other Linux distributions and operating systems.)

Sansa Clip+ derives the play-order by looking at the “NUMBER” tag. EasyTAG displays this as the “Track”.

The NUMBER tag for each track has to have the same number of digits, so it usually has to be padded with leading zeros.

That is, tracks numbered like this will not work: 1, 2, 3, … 8, 9, 10, 11… because the Sansa player will sort tracks 10 and 11 before track 2 (which obviously will screw up the literary experience considerably).

Padding with leading zeros will solve this: 01, 02, 03, … 08, 09, 10, 11…

In EasyTAG, this padding is not automatic, but has to be specified by the user under Settings -> Preferences -> Tag Settings -> “Write the Track field with the following number of digits” (which I have set to 3, because I’ve never encountered an audiobook with more than 1000 files in it – 001, 002, 003, … 008, 009, 010, 011…).

Some more random tips from the Sansa forums (I haven’t verified that they are needed) is the following.

  • Do not specify the total number of tracks (like 01/87, 02/87, 03/87) because that may confuse the player. Just leave that field empty..?
  • Make sure that the GENRE tag is set to “Audiobook”…?

End of post.


The player will not handle the case with tracks in multiple subdirectories well. I think..? So one may as well move all files to one and the same directory, and then use EasyTAG to set the correct Track tag (NUMBER) on all of them. The following little script copies all mp3 files from within a directory tree to a directory named tmp. The file name of the new file while be $DIRNAME.x.$OLD_FILENAME (so that no filename information will get lost) rather than just $OLD_FILENAME.


mkdir tmp ;

find * -name *mp3 | while read FILE ; do
 NEWFILE=`echo "$FILE" | sed 's/\//.x./'` ;
 echo "Copying tmp/$NEWFILE" ;
 cp "$FILE" "tmp/$NEWFILE" ;

It would be cool if one could just create the zero padded track numbers command line (i.e without needing to open EasyTAG), using something like this:

for FILE in tmp/* ; do
  PADDEDNUMBER=`printf "%03d" "$NUMBER"`;
  echo "Tagging $FILE. Track number will be: $PADDEDNUMBER"
  # eyeD3 --track="$PADDEDNUMBER" "$FILE" | grep title
  # id3v2 --track "$PADDEDNUMBER" "$FILE"

I’ve tried both eyeD3 and id3v2. Neither seems to create the necessary padding of leading zeros (at least not if there are more than 100 files). So — EasyTAG it is!