[Greasemonkey] Thanks for OSCON presentation

Dave Land land at aol.com
Tue Aug 9 11:03:43 EDT 2005


On Aug 9, 2005, at 9:30 AM, Kirby Krueger wrote:

> I was really impressed (and surprised) at how _easy_ it was.  Aaron
> gave a live demo on adding in a 'Kevin Bacon Number' to IMDB.  (The
> only talk I went to that actually wrote code on the fly.)  Even over
> the extremely flaky conference wireless, it worked smoothly, and left
> me thinking, "Wow, I could do that."

Yep. First, there's the "Wow, I could do that" stage. Then, there's the
"It always drives me crazy that (frequently-visited page) (does stupid
thing)" phase, with the realization that you can do something about it.

My first couple of scripts were revisions of existing scripts, as I
learned my way around XPATH (not *necessary*, strictly speaking, but
helpful for some mass-change scripts, lived through the security scare
(0.3.4 --> 0.3.5 --> 0.5) and generally gained an understanding of
how it all fits together. And you're right: it is impressively,
surprisingly easy.

Don't be afraid to write scripts that don't do all that much. Sometimes,
not much needs to be done! Take a look at ununderline.user.js, for
example:

// ==UserScript==
// @description Converts underlined text to italics, making it more 
distinguishable from a hyperlink.
// ==/UserScript==

(function () {
    var ss = document.createElement("style");
    var t = document.createTextNode("u { text-decoration:none!important; 
font-style:italic!important; }");
     var root = (document.getElementsByTagName("head")[0] || 
document.getElementsByTagName("body")[0]);
    ss.appendChild(t);
    root.appendChild(ss);
})();

All it does is add a style element (to the head OR body, but only if
necessary) to restyle <u>underlined</u> text to italics. Just one thing.

I've used its model to fix layout problems on phpmyadmin, which I use
quite a bit.

At the other extreme are sheer works of art like Magic Line
(http://diveintomark.org/projects/greasemonkey/magicline.user.js) by
Mark Pilgrim, one of the brightest lights in the Greasemonkey firmament.

Dave Land



More information about the Greasemonkey mailing list