Created
April 22, 2012 02:02
-
-
Save bamanzi/2440796 to your computer and use it in GitHub Desktop.
[firefox] let `tabbundle' only snapshot tabs in current group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let `tabbundle' only snapshot tabs in current group | |
// put these code into: | |
// extensions\tabundle@relucks.org\chrome\content\tabundle.js | |
Tabundle.bundle = function() { | |
Tabundle.createIndexHtml() | |
//var path = Tabundle.createListHtml() | |
var path = Tabundle.createGroupListHtml(); | |
if (path) { | |
gBrowser.selectedTab = gBrowser.addTab('file://' + path) | |
} | |
} | |
// working with firefox 4+'s tabcandy (panorama) | |
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 | |
} | |
} | |
//working with TabGroupManager | |
Tabundle.createTGMGroupListHtml = 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"; | |
//... the same with the above one | |
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment