Friday, February 12, 2010

Saving tab sets in Firefox

I blogged last summer about Using Mozilla Jetpack to save tab ensembles, giving a bit of POC-quality code, but now Davide Ficano has done a proper job of things and written a Jetpack script that lets you name and persist open-tab states, using a very natural set of UI gestures.

TabGroup Organizer allows you to save all open tabs as a group and then reopen all with a click. After installation, a new multifolder icon (that gives rise to a context menu when right-clicked) is present on the statusbar in the lower-right corner of the browser window:



Using this Jetpack script, I can finally save tab ensembles and come back to them later -- a real productivity win, for me. Thank you, Davide!

And since the code is open-source, I'm going to reproduce it here (scroll sideways to see the parts that don't wrap):

jetpack.future.import("menu");
jetpack.future.import("storage.simple");

var tabGroupStorage = jetpack.storage.simple;

jetpack.statusBar.append({
html: "<img src='data:binary;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAADdgAAA3YBfdWCzAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAGiSURBVDiNrZUxayJBGIafb9zWU6ukEQ7ObuEIpEqTMiDslf6L%2Bxd3%2F%2BT%2BQlKkszqEg8AWiiI2SghiI6dyiDP7pQi72birNwm%2BMDDMzPt%2BL%2FO9Oyuqig9E5AwIASnZVmCkqo%2BvK6r%2FHcB5r9eb7na7xFqbWGt1byRxHD8Bn1OO%2BDgWkRtr7f1sNjt4ptlsEgRBpKp3AIHXPUBgjAGgXq8XNpfLJSICYDKCiNRbrVYEaPICBXDOqXMuUVWt1WpfPA28OgEuR6PRr9TRRyAiqeM3wgBMp9ODpBSVSoXFYsFwOCTfm81mw3g8BvgqIg%2Bq%2BhjkSdVq9aiz%2BXzOarWi3W4XHAJYa3%2F2%2B%2F3vInKVCRtjSg%2FnMRgMiKKIY%2BkIw%2FAcCN8lbK3FNx2Z8Hq9ptvtvmnE%2FnwymRwtnEcmHMcxnU6HU6UjyC%2BCfzrKri1vKtiv5JOOQygIA5mYTxN9hf8YY74BF865HycTVtW%2FwK2I%2FDuF40LzUpR9977I80qFfcn7KG1eSjLGsN1u%2FW0eKFpw3Gg0PiRaKJI%2BfyLyCbim%2FGf5Xvx%2BBkJNxrS0dvEEAAAAAElFTkSuQmCC' width='20px'>",
onReady: function(doc) {
jetpack.menu.context.set([
{label: "Save Tabs...",
command: function() {
var win = jetpack.tabs.focused.contentWindow;
var name = win.prompt("Enter the name for tabs group");
if (name) {
var arr = [];
jetpack.tabs.forEach(function(tab) {
arr.push(tab.url);
});
tabGroupStorage[name] = arr;
jetpack.storage.simple.sync();
}
}},
{label : "Restore tabs",
menu: new jetpack.Menu({
beforeShow : function(menuitem, context) {
menuitem.set([]);
for (var i in tabGroupStorage) {
menuitem.add({label : i + " (" + tabGroupStorage[i].length + ")", data : i});
}
}}),
command : function(menuitem) {
tabGroupStorage[menuitem.data].forEach(function(url) {
jetpack.tabs.open(url);
});
jetpack.storage.live.lastUsedGroup = menuitem.data;
}},
{label: "Delete Group...",
command: function() {
var win = jetpack.tabs.focused.contentWindow;
if (typeof (jetpack.storage.live.lastUsedGroup) != "undefined") {
if (win.confirm("Delete the current group '" + jetpack.storage.live.lastUsedGroup + "'?'")) {
delete tabGroupStorage[jetpack.storage.live.lastUsedGroup];
delete jetpack.storage.live.lastUsedGroup;
}
} else {
win.alert("You must select a group from menu before delete it");
}
}},
]);
}
});
The data URL -- the big long line near the top that contains
data:binary;base64,iVBORw0K ...
-- is of course the raw bytestream for the multifolder icon. The rest of the code is more or less self-explanatory. It uses the jetpack.storage.simple mechanism for persistence.

Nice going, Davide Ficano. Ten thumbs up!

7 comments:

  1. Just wanna point out that this has been builtin in Opera since... ever? ;)

    ReplyDelete
  2. The packer and movers in Hyderabad load and unload your household items using the necessary equipment and techniques depending on your specific requirements. Fragile household items are handled with extra care, and you can rest assured that you are leaving your irreplaceable assets in good hands.
    Movers and Packers in Gachibowli
    Movers and Packers in Kukatpally
    Movers and Packers in Chanda Nagar
    Movers and Packers in Manikonda

    ReplyDelete
  3. You can forget your stress and anxiety with the help of best movers and packers in Hyderabad who take on the responsibility of shifting your household goods.
    Packers and Movers in Nallagandla
    Packers and Movers in Kukatpally
    Packers and Movers in Miyapur

    ReplyDelete
  4. Thanks for your stop at Indian Packers and Movers in Mumbai. We really know the intentions of the people who are moving their homes or offices in Mumbai. We are one of the best Packers And Movers in Mumbai that gives values to the suggestions and recommendations of the client. It is this heart reading and friendly packing and moving service that made us the most loved packers and movers in Mumbai to depend for professional local transport in Mumbai, courier services in Mumbai and relocation services Mumbai and more.
    Please Visit Our Website : https://indianpackersmovers.in/
    Movers and Packers in Dadar
    Movers and Packers in Thane
    Movers and Packers in Panvel
    Packers and Movers in Kamothe
    Movers and Packers in Vashi

    ReplyDelete
  5. Indian Packers and Movers in Mumbai is the best packing and moving company in Mumbai. Of course, the credit goes to our hardworking team in Mumbai and world class infrastructure. Customer satisfaction is a great asset for the company.
    Packers and Movers in Mumbai
    Packers and Movers in Nahur
    Packers and Movers in Mulund
    Packers and Movers in Thane
    Packers and Movers in Kalyan

    ReplyDelete
  6. We provide a wide range of computer chairs, ergonomic chairs, leather chairs and thus, we are leading manufacturer of office furniture chairs. We supply products not only to local clients but also to national and international clients.
    Visitor Chair Supplier in Mumbai
    Chair Dealers in Mumbai
    Top Chair Manufacturers in Mumbai
    Best Chair Manufacturers in Mumbai

    ReplyDelete

Add a comment. Registration required because trolls.