Paul Wright's software

Here's some stuff I wrote, along with some other people's stuff I am distributing.

LJ New Comments

This is a script for Greasemonkey, the Firefox extension which lets you write little bits of Javascript to alter the appearance and function of web pages. What it does is remember which comments on LiveJournal you've already seen, marking up the new ones for you. It lets you navigate to new comments by pressing keys, and does a couple of other clever tricks too. At long last, I'm dragging LiveJournal's user interface kicking and screaming into the 1980s.

You can read more about it on my my LiveJournal entry about it (which is also the right place to post questions or comments about it), and download it from the userscripts.org repository.


URLBody

URLBody is an extension for the Spampal spam filter, which filters out spam based on the links in the body of messages. I no longer have a machine which can run Windows, so I'm not maintaining it any more, but it works well enough that there's not really any need for further changes. Read about it on the SourceForge site for it.


mozex-helper for Mac OS X

Mozex is an extension for the Mozilla/Firefox browser. The most useful thing about it is that it lets you edit textareas (the boxes where you enter text on a web page, such as when you're posting a comment to a site, say) with an external editor. When combined with Vim and the Google script for making a link to the top Google result for the highlighted text, this ability makes posting such comments a lot easier.

There are a couple of ways to make it work on Mac OS X.

Use Firefox 1.5 or later (including Firefox 2.x)

Get the latest version of Firefox (version 2.x at the time of writing), along with the development version of Mozex. If you've got those, Mozex just works as intended, with no need to mess about with scripts and so on mentioned below. If you want to use Mozex, by far the easiest thing to do is upgrade to the latest version of Firefox. Vladimir Marek, who has recently taken over development of Mozex, tells me that there'll soon be an official release which supports Mac OS X, too.

Install Firefox and the development version of Mozex. Then go to the Tools menu, click Extensions, click on the entry for Mozex and then click the Preferences button. To get it going with the Vim editor, enter the temporary directory as /tmp/ and the textarea edit command as /Applications/Vim.app/Contents/MacOS/Vim -g %t. You can now command-click on comment boxes and go to Mozex and then Edit textarea. This brings up a Vim window in which you can edit the text. When you're done, save your text and exit Vim, and then click on the comment box. Mozex will insert the text there.

Using Firefox 1.0

Note: If you just want it to work, install the latest version of Firefox and follow the instructions above. If you have a sentimental attachment to Firefox 1.0 and enjoy pain, read on. (This is old information from the pre-FF1.5 days, which I'm keeping here in case anyone still finds it useful).

Unfortunately there are complications with getting Mozex going on Firefox 1.0 or earlier for MacOS X, which result in the following fairly disgusting hack. If you want to use it, you'll need to be comfortable with working with the shell prompt (Terminal) and with changing some obvious bits in code files. You will also need the Developer Tools installed. If you just want to know how to get the thing working, skip to the Installation section. If you're curious about what's going on, then read the rest first.

Mozex is old

The first is that it's an old style extension from the days before Firefox 1.0. Firefox seems to have changed its extension format at some point. Luckily, the Install Old Extensions extension lets you at least play with the configuration for Mozex. Click on Tools->Extensions and then hit the Options button to set it up. Maybe. I found I had to set values from about:config (type mozex into the filter bar to cut down on the amount of stuff this shows you) as the dialog which popped up from the Options button would truncate the settings.

(You could also try the updated version of Mozex as that's reputed to work with Firefox 1.0: I discovered it after writing these instructions for the first time).

nsIProcess buggy on the Mac

I want Vim for Cocoa to be my editor. Looking at the MacVim site, my first thought was to specify the editor as /Applications/Vim.app/Contents/MacOS/Vim -g %t (see the Mozex arguments page: %t is the name of the file to be edited).

Alas, this throws an exception. After much hunting around with Google, I conclude that the Mac implementation of nsIProcess is buggy. nsIProcess is the interface Mozilla provides for programmers to start external processes, so Mozex uses it, not unreasonably. The bug appears to be that it doesn't allow you to pass arguments to the process. I confirmed this by just having it start Vim alone, with no arguments. Unfortunately, this makes it tricky to tell it which file you want to edit.

This blog posting inspired me to get around it: I wrote a Python script which finds the most recent file in a given directory and invokes the gvim script on it. This works because even if you've got another Mozex edited file on the go, at the point where you invoke Mozex a second or third time, the file it creates just before invoking the mozex-helper will always be the most recent one.

Alas, Firefox/Mozilla won't run mozex-helper.py directly (because the #!/usr/bin/python syntax is actually interpreted by the shell, I believe), so I wrote a C stub to call it. With this in place, it all works. You may ask why I didn't just write the whole thing in C: the answer is that I can't find a means of comparing struct timespecs returned by the stat function. It seems there should be a macro or function to do this without having to break the abstraction by reading the system header file to find out what's in the bloody thing. If you know how, why not let me know?

Installation