Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created March 18, 2009 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotchpotch/81090 to your computer and use it in GitHub Desktop.
Save hotchpotch/81090 to your computer and use it in GitHub Desktop.
commands.addUserCommand(['bdd[omain]'],
'buffer delete by match domain',
function (args) {
var domain = args.string;
let count = 0;
Application.activeWindow.tabs.forEach(function(t) {
// t #=> fuelIBrowserTab
if (t.uri.scheme.indexOf('http') != -1 &&
t.uri.host.indexOf(domain) != -1) {
t.close();
count++;
}
});
if (count) liberator.echo('close ' + count + ' buffer(s).');
},
{
completer: function (context) {
context.title = ['domains', ''];
let domains = [];
Application.activeWindow.tabs.forEach(function(t) {
if (t.uri.scheme.indexOf('http') != -1) {
if (!domains.some(function(domain) t.uri.host == domain))
domains.push(t.uri.host);
}
});
context.completions = domains.map(function(d) [d, '']);
},
argCount: '1',
bang: false,
},
true
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment