Greasemonkey Insecure

Update: There’s a neutered version available until this bug can be fixed. Thanks to maca for pointing this out in the comments. I should also add that the maintainers are doing a great job sorting this problem out.

Since I’ve spouted here about the virtues of the Greasemonkey extension for Firefox, I should probably point out that, as of right now, Greasemonkey is completely insecure. That is, if you have it installed you should uninstall or disable it. I’m not kidding. There’s already a proof-of-concept exploit that demonstrates that any page that you run a Greasemonkey script on (which usually means any page at all since Greasemonkey scripts execute on all pages by default) can access any file on your computer and send its contents to any server.

Uninstall Greasemonkey altogether. At this point, I don’t trust having it on my computer at all. I would think that whoever is in charge of addons.mozilla.org should immediately remove the Greasemonkey XPI and post a large warning in its place advising people to uninstall it.

— Mark Pilgrim

Recursing HTML Frames in Javascript

Sometimes you want to apply a javascript function to an entire page. Maybe you want to replace all of the images with their alt text, maybe you want to open all of the links in new windows, maybe you want to remove the target attributes from links so they don’t open new windows. Bookmarklets usually do something like this, as do Greasemonkey scripts, and sometimes page authors want these functions. It’s as simple as using a couple of document.getElementsByTagName()s and similar functions.

Unfortunately this is singularly unhelpful when dealing with frames-based pages. If your page consists of, say, two frames each of which contains another page and you want to enumerate the links in the child pages you can’t do a simple document.getElementsByTagName("a"). That’ll give you back an empty array, since the frameset page itself (usually) contains no such elements. You need to recurse through the frames and apply the function to every document in the frameset.

Continue reading “Recursing HTML Frames in Javascript”

Greasemonkey

I’ve heard a lot of talk of Greasemonkey recently. Since I’m barely awake right now I can’t actually remember if it’s all from the same source or not, but I think there’s some small increase in the buzz around this right now. I’ve had this nifty little extension for a while, but it’s only since other people have told me what to think that I actually start to see some major potential in it. Actually, some of that potential has already been released.

Okay, rewind. You probably don’t even know what the hell I’m talking about. I’ll start again. Greasemonkey is a Firefox extension that lets you associate user scripts with particular web sites (including wildcards so you can apply them to all sites or just some subset of the Web). The scripts are run on the page after it loads just as if they were included on the page. The interface for installing and managing the scripts is very polished by extensions’ standards. You just load the script in Firefox and click on a "Install User Script…" menu item.

Continue reading “Greasemonkey”