December 09, 2004
Open a URL within Thunderbird's Mail Start Page
Here is how to load a URL from an extension in Thunderbird, into the Mail Start Page area:
var url = "http://mesh.typepad.com";
var browser = document.getElementById("messagepane");
browser.loadURI(url, browser.currentURL, null);
That will allow you to change the current document loaded in the Mail Start Page (email reading) area of Thunderbird.
December 9, 2004 in Thunderbird Development | Permalink | Comments (3)
Opening an URL in an External Browser from a Thunderbird Extension
Here is a quick code snippet that shows how to open a URL in an external browser from within a Thunderbird extension:
var url = "http://mesh.typepad.com";
var uri = Components. classes["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService).newURI(url, null, null);
var com = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"];
var httpHandler = com.createInstance(Components.interfaces.nsIExternalProtocolService);
httpHandler.loadUrl(uri);
This will open the URL in the system's default web browser.
December 9, 2004 in Thunderbird Development | Permalink | Comments (2)
Determining whether your extension is running in FireFox or Thunderbird
One of the things that is cool about building extensions for FireFox, is that in most cases they can easily made to run within Thunderbird. However, sometimes your extension needs to know which environment it is running within. You can determine this by checking the navigator.vendor property.
var firefox = false;
var thunderbird = false;
var vendor = navigator.vendor;
if(vendor == "FireFox")
{
firefox = true;
}
else if(vendor == "Thunderbird")
{
thunderbird = true;
}
dump("Running in FireFox : " + firefox + "\n");
dump("Running in Thunderbird : " + thunderbird + "\n");
This makes it easy to branch your code when necessary.
December 9, 2004 in FireFox Development, Thunderbird Development | Permalink | Comments (2)
Debugging Thunderbird Extensions on OS X
Well, now that I have gotten my first FireFox extension working, I decided to see if I could make it run within Thunderbird. The first issue I ran into was trying to figure out how to debug extensions within Thunderbird. It took me a while to figure it out, but it is pretty much the same as in FireFox.
First, you have to set the following Thunderbird preference to true:
browser.dom.window.dump.enabled
However, there is not an easy way (such as FireFox's about:config) to set the preference. In order to set it, you need to add the following line to your user.js file in your Thunderbird profile directory:
user_pref("browser.dom.window.dump.enabled", true);
If the file doesn't exist (it doesn't by default), just create it. You can find more info on setting Thunderbird preferences here.
This setting will redirect dump() statements from your extension to the console.
In order to view the dump statements, you have to start Thunderbird from the console / terminal. You can do this on OS X with the following command line (replace the path to match your system):
/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin
Now, if you add:
debug("Hello World\n");
To you extension, then you will see:
Hello World
output to the console / terminal that you started Thunderbird from.
You can now debug Thunderbird extensions the same way you debug FireFox extensions.
December 9, 2004 in Thunderbird Development | Permalink | Comments (0)
