Last active
December 24, 2015 09:39
-
-
Save ivanatpr/6778327 to your computer and use it in GitHub Desktop.
Tree Style Tab specific scripts for use as user scripts within the FireGesture Firefox add-on. Scripts include: Close Current Tree; Close Children; Close Entire Tree (including parents); Close others except this tree
Note: In order to use these you have to create a separate user script for each one.
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
/* Close Current Tree: Closes Current tabs and all descendants */ | |
selTab = gBrowser.selectedTab; | |
TreeStyleTabService.getDescendantTabs(selTab).forEach(function(tab) { | |
try | |
{ | |
gBrowser.removeTab(tab); | |
} | |
catch(e) | |
{ | |
console.log("Failed to remove" + tab.label) | |
} | |
}); | |
gBrowser.removeTab(selTab); | |
/* Close Current Tree: Closes Current tabs's descendants */ | |
selTab = gBrowser.selectedTab; | |
TreeStyleTabService.getDescendantTabs(selTab).forEach(function(tab) { | |
try | |
{ | |
gBrowser.removeTab(tab); | |
} | |
catch(e) | |
{ | |
console.log("Failed to remove" + tab.label) | |
} | |
}); | |
/* Close Entire Tree: Closes all tabs within the current tree (not just descendants but parents as well)*/ | |
selTab = TreeStyleTabService.getRootTab(gBrowser.selectedTab); | |
TreeStyleTabService.getDescendantTabs(selTab).forEach(function(tab) { | |
try | |
{ | |
gBrowser.removeTab(tab); | |
} | |
catch(e) | |
{ | |
console.log("Failed to remove" + tab.label) | |
} | |
}); | |
gBrowser.removeTab(selTab); | |
/* Close others except this tree: CLoses all tabs except the current tab its descendants */ | |
selTab = gBrowser.selectedTab; | |
tabsToKeep = TreeStyleTabService.getDescendantTabs(selTab); | |
tabsToKeep.push(selTab); | |
alltabs = Array.prototype.slice.call(gBrowser.tabs); | |
//Array.prototype.forEach.call(alltabs, function( tab ){ | |
alltabs.forEach(function( tab ){ | |
if(tabsToKeep.indexOf(tab) === -1) | |
{ | |
try | |
{ | |
gBrowser.removeTab(tab); | |
} | |
catch(e) | |
{ | |
console.log("Failed to remove" + tab.label) | |
} | |
}; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment