Categories
Uncategorized

Greasemonkey Hacks

I’ve just gotten a copy of Greasemonkey Hacks and I’m working my way through it. The book itself is great. It’s a really good introduction to greasemonkey and what you can do with it. Eventually, I’m hoping to may my bank usable in firefox.

The only quibble that I have is the code samples. Many of them (and they appears to be the ones written by Mark Pilgrim, the author) are really difficult to read, because they idioms are wrong. For example, nearly every for loop I have seen looks like this:

  for (var i = arTableRows.length - 1; i > = 0; i--) {
    ...
  }

Which is walking through the rows of a table, backwards. Why backwards? I have no idea. I would expect it to look more like this:

  for (var i = 0; i < arTableRows.length; i++) {
    ...
  }

Aside from a marginal efficiency gain (which smacks of micro-optimisation), I don’t see what the benefit is.

And “arTableRows” is another quibble with the code. It’s filled with hungarian notation. Great if you work at Microsoft, but unreadable to the rest of the world.

Categories
Uncategorized

Citation Sources

One of the useful things about blockquotes is that you can specify where you’re quoting by adding a cite attribute. But current browsers don’t offer you an interface to use this information. Sounds like a job for greasemonkey! So I wrote cite.user.js to get around it.

Unfortunately, I should have looked around first—I might have seen Citeable Blockquotes, which does what my script does, but more and better. Ah well. It was an interesting learning experience; it took only minutes to put together.