redditlet

Below is some helper javascript for writing bookmarklets for reddit along with two tests.

reddit.js
test/names.js
test/points.js

The idea is that most of the time, you are simply looping over all the entries. So, reddit.js provides the function entries(func,before,after), which will call before(), then loop over all the entries, calling func(r) on all the entries r, then call after(). The value r is defined in reddit.js and contains an object of type Reddit, with the following signature:

Link
 String href
 String text

Reddit
 Link title
 Link site
 String time
 Link user
 Link subreddit
 String points
 Link comments

You combine your code after reddit.js (perhaps using my ruby script create_bookmarklet), to create the final script. For example:

create_bookmarklet reddit.js test/names.js

Which will produce out.js (as well as copying the output to the clipboard, so you can test easily) that can be used in a bookmarklet, such as

alert names

That will will alert all the names of the entries. The code in test/names.js is simply:

/* Appends all the names of the entries to the top of the body */
var msg;
function  before() {msg = '';}
function after() {alert(msg);}
function func(r) {msg += r.title.text + "\n";}
entries(func,before,after);