Skip to content

Instantly share code, notes, and snippets.

@bamanzi
Created February 17, 2012 08:17
Show Gist options
  • Save bamanzi/1851778 to your computer and use it in GitHub Desktop.
Save bamanzi/1851778 to your computer and use it in GitHub Desktop.
[firefox] hacking tabundle extension: only list tabs in current group (panorama)
//extensions/tabundle@relucks.org/chrome/content/tabundle.js
Tabundle.createGroupListHtml = function() {
var height = window.innerHeight;
var currentGroup = TabView._window.GroupItems.getActiveGroupItem();
var list = Array.map(currentGroup._children, function(tabitem) {
var w = gBrowser.getBrowserForTab(tabitem.tab).contentWindow
var c = Tabundle.capture(w, {x: 0, y:0}, {h: height, w: w.innerWidth}, 0.3)
return [w.document.title, w.location.href, c]
})
var date = Tabundle.dateString();
var size = currentGroup._children.length.toString();
var group = currentGroup.getTitle();
var opt = {
list: list,
size: size,
date: date,
title: "[" + group + "]: " + size + 'tabs ' + date,
fav: Tabundle.icon(size).toDataURL(),
style: Tabundle.style()
}
var html = Tabundle.listHtml(opt)
var fileName = date + "-" + group + '.html'
var out = Tabundle.IOUtils.getFile(Tabundle.getHtmlDir())
out.append(fileName);
var path = out.path;
if (out.exists()) {
var opt = {
mode: Components.interfaces.nsIFilePicker.modeSave,
defaultString: fileName,
displayDirectory: Tabundle.IOUtils.getFile(Tabundle.getHtmlDir()),
filters: Components.interfaces.nsIFilePicker.filterHTML
}
path = Tabundle.selectFile(opt)
}
if (path) {
Tabundle.IOUtils.write(path, html)
return path
}
}
//then replace all occurrence of `createListHtml' to `createGroupListHtml'
@bamanzi
Copy link
Author

bamanzi commented Jan 26, 2013

to support groups of TabGroups Manager, the first lines should be:

Tabundle.createGroupListHtml = function() {
    var height = window.innerHeight;
    var currentGroup = TabGroupsManager.allGroups.selectedGroup;
    var list = Array.map(currentGroup.tabArray, function(tabitem) {
        var w = gBrowser.getBrowserForTab(tabitem).contentWindow
        var c = Tabundle.capture(w, {x: 0, y:0}, {h: height, w: w.innerWidth}, 0.3)
        return [w.document.title, w.location.href, c]
    })
    var date = Tabundle.dateString();
    var size = currentGroup.tabArray.length.toString();
    var group = currentGroup.name || "noname";
    //...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment