[Greasemonkey] Monkey Do

Mark Pilgrim pilgrim at gmail.com
Wed Aug 17 18:12:20 EDT 2005


I have long believed[1] that blogging, when done at all, should be the
byproduct of my activity online, rather than an activity in and of
itself.  To this end, I set out to create a personal "blogging
byproduct" agent, one that would sit in the background and watch me as
I browsed, and automatically post things I found interesting.

That went precisely nowhere.

In my second attempt, I tried to identify a number of different types
of pages that I generally find interesting.  Things such as
- books
- specifications
- bug reports
- auctions
- food recipes
- Greasemonkey scripts

I augmented this list with things that other people seem to find
consistently interesting[2], including
- tutorials
- "top 10" lists
- software to download
- articles by Paul Graham

And this is the result:

http://diveintomark.org/projects/greasemonkey/monkeydo.user.js

Think of it as Clippy the Useless Office Assistant, only for the web,
and actually useful.  (I actually considered naming it Cl.ip.py, but
thought better of it.)  It sits in the background and watches as you
browse, and if it recognizes a type of page that you consider
interesting (as defined in Tools --> User Script Commands --> Monkey
Do options), it will offer to post it to del.icio.us.  Or if you
prefer, you can tell it to automatically post certain types of pages,
and it will simply notify you when it has done so.

The heuristic for identifying different types of pages is, of course,
somewhat messy, and will inevitably lead to embarrassingly hilarious
mis-identification, which someone will no doubt bring to my attention.

Some test pages that work as intended:
http://diveintopython.org/ (tutorial)
https://bugzilla.mozilla.org/show_bug.cgi?id=291218 (bug report)
http://www.epicurious.com/recipes/recipe_views/views/104489 (recipe)
http://www.cnet.com/4520-11136_1-6268155-1.html (top 10 list)
http://www.w3.org/TR/xhtml-media-types/ (specification)
http://paulgraham.com/opensource.html (Paul Graham essay)
any eBay auction item page
any book page on Amazon, BN.com, Powells, or Half.com

I would also like to point out the forceStyle() function, which is my
answer to the oft-asked question[3], "How do I add elements to a page
without inheriting the page's CSS?"  Answer: call
forceStyle(myRootElement), and it will apply the default styles for
every CSS property except the ones you've explicitly defined.  And
then it will do it again, recursively, on all the element's children.

Considering that I have published one-line user scripts that have gone
through 5 revisions, and forceStyle() is over 300 lines long, it is
possible that there are still a few bugs to be shaken out.  But there
it is.

Notes:
[1] http://diveintomark.org/archives/2003/01/28/autocontent
[2] http://del.icio.us/popular/
[3] http://mozdev.org/pipermail/greasemonkey/2005-August/004772.html

-- 
Cheers,
-Mark


More information about the Greasemonkey mailing list