Skip to content

Instantly share code, notes, and snippets.

@satyr
Created January 29, 2010 17:27
Show Gist options
  • Save satyr/289922 to your computer and use it in GitHub Desktop.
Save satyr/289922 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: 'sort tabs',
description: 'Sorts tabs in the current window.',
author: {name: 'satyr', email: 'murky.satyr\100gmail.com'},
license: 'MIT',
icon: 'chrome://ubiquity/skin/icons/favicon.ico',
arguments: {
object: CmdUtils.NounType('method', {
'by title': function(t) t.linkedBrowser.contentTitle,
'by host': function(t) t.linkedBrowser.currentURI.host,
'by URI': function(t) t.linkedBrowser.currentURI.spec,
'by priority': function(t) (
(t.getAttribute('protected') !== 'true') * 2 +
(t.getAttribute('locked') !== 'true')),
chronogically: 'linkedPanel',
randomly: Math.random,
}, '^by host'),
format: CmdUtils.NounType('order', {ascending: 0, descending: 1}, '^a'),
},
execute: function({object: {data: method}, format: {data: order}}){
var {gBrowser} = Utils.currentChromeWindow;
var tabs = Utils.sortBy(Array.slice(gBrowser.mTabs), method, order);
for each(let t in tabs.reverse()) gBrowser.moveTabTo(t, 0);
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment