Alexis Brunet

BitTorrent WebUI Firefox Extension

BitTorrent WebUI is no longer being maintained, the last version is available at
This Firefox extension allows you to simply click a download link for a torrent file and have it automatically uploaded to your Bit Torrent client through your preffered web interface. This is especially useful if you do a lot of browsing on a different computer than the one which is running your Bit Torrent client.

Supported Clients:


Since I use the HTML WebUI plugin to control Azureus (which I run headless on a Linux server) I got tired of always having to copy paste .torrent links to the upload form of Az's WebUI. So I made a Firefox extension which automatically downloads .torrent files and then uploads them to my Azureus WebUI. The result is pretty seamless, click on the download link of a bittorrent file and you receive a nice little message telling you if it worked or not.

Here's how it works.

high level sequence diagram

The extension registers itself as a content listener with Firefox, when a new channel is opened we are given the content-type of the channel, if the content-type is that of a .torrent file (application/x-bittorrent) then BitTorrent WebUI supplies an instance of StreamListener, effectively taking over the data transfer. Once the transfer is completed, the StreamListener calls back the extension passing it the channel data (the contents of the .torrent file).

The extension then requests a dispatcher from the dispatcher factory, the dispatcher factory returns a concrete dispatcher based on the BitTorrent client selected in the extension preferences. The dispatcher then creates a post request specifically for the selected web interface, and sends it to the URL of the web interface. The result of the POST request is then parsed and displayed using Firefox's alert service.

Early on I realised that I would get requests to support different BitTorrent clients and remote control plugins so I decided to design the extension so that it could easily accommodate these changes.

Here is an overview of the Dispatcher object hierarchy. (I'm using "object" here because classes don't really make sense in the context of JavaScript)

class diagram for a language without classes

Each BitTorrent client / WebUI has its own dispatcher based on the prototype dispatcher object (kind of like a base class). Dispatchers use the Template Method Pattern to customize the process of creating a POST request containing the torrent file data.

Concrete Dispatcher objects can "hook" into 4 steps of creating and sending the torrent data

That way I can add support for a new client by writing one new file which defines a new dispatcher object and registers it with the dispatcher factory, no other modifications are necessary.