Mozilla Ubiquity was released this week, and the functionality was so inspiring that I couldn't help playing with it. For those that haven't checked it out yet, think "Quicksilver inside Firefox"... or perhaps, "a contextually-aware command-line for your web browser." If that still doesn't mean anything to you... well, you'll have to watch the intro video ;-)
Extending Ubiquity's vocabulary is done via JavaScript, and the developer docs are pretty straight forward.
The docs cover Hello World, so I figured that the next best intro test would be a way to lookup stock charts and quotes. Here's the result of a few minutes hacking on it:
CmdUtils.CreateCommand({
name: "tik",
takes: {"stock ticker symbol": noun_arb_text},
preview: function( pblock, argText ) {
var charturl = "http://chart.finance.yahoo.com/c/1y/a/" + argText.text;
pblock.innerHTML = "![]()";
},
execute: function( argText ) {
var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
var url = "http://finance.google.com/finance?q=" + argText.text;
browser.loadOneTab(url, null, null, null, false, false);
}
})
This command introduces a 'tik' keyword, which loads 1-year stock symbol charts (from Yahoo) into the preview pane, and allows click-through to open a new tab for the Google Finance page of said symbol. Note that the preview-pane doesn't always resize correctly for the chart to fit (though you can generally make it happen by typing a space after the stock symbol.) I guess there's still some work to do there.