Hi, I have here Ubiquity 0.5.5pre7 from addons.m.o website on Fedora/Rawhide (x86_64). In order to learn ubiquity ways I am trying to write a simple deduplication script. It should look something like this (close_duplicates function is something I would like my new command look like):
CmdUtils.CreateCommand({
names: ["deduplicate"],
icon: "http://www.ceplovi.cz/favicon.ico",
description: "Remove all duplicate commands from your browser.",
help: "It should Just Work™ automagically.",
author: {name: "Matěj Cepl", email: "[email protected]"},
license: "MIT",
homepage: "http://mcepl.fedorapeople.org/",
execute: function execute() {
// var tabs = Utils.tabs.get();
displayMessage(Utils.tabs.search("^.*youtube.*$"));
}
});
function close_duplicates()
{
var closeArray = new Array();
var urlList = new Object();
var browserTabs = gBrowser.mTabContainer.childNodes;
for (var i = browserTabs.length-1; i >= 0; i--)
{
var tabURI = gBrowser.getBrowserAtIndex(i).currentURI.spec;
if (urlList[tabURI])
{
closeArray[closeArray.length] = i;
}
else
{
urlList[tabURI] = true;
}
}
for (i = 0, max = closeArray.length; i < max; i++)
{
gBrowser.removeTab(browserTabs[closeArray[i]]);
}
}
The weird thing is that in the current state both Utils.tabs.get and
Utils.tabs.search give me undefined values, although I do have YouTube
tabs opened.
Any idea, what's going on? Where's my mistake?
Thanks for any hint,
Matěj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
Microwave oven? Whaddya mean, it's a microwave oven? I've been
watching Channel 4 on the thing for two weeks.
smime.p7s
Description: S/MIME Cryptographic Signature
