Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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