1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 06:17:58 +01:00

:bdelete google to close all tabs from google

This commit is contained in:
Martin Stubenschrott
2008-06-08 05:38:34 +00:00
parent 4a81ae7b11
commit 9d38f46dd3
5 changed files with 58 additions and 13 deletions

View File

@@ -260,8 +260,43 @@ liberator.Tabs = function () //{{{
"Delete current buffer",
function (args, special, count)
{
liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
});
if (args)
{
args = args.toLowerCase();
var removed = 0;
var match;
if (match = args.match(/^(\d+):?/))
{
liberator.tabs.remove(liberator.tabs.getTab(parseInt(match[1], 10) - 1));
removed = 1;
}
else
{
var browsers = getBrowser().browsers;
for (let i = browsers.length - 1; i >= 0; i--)
{
var title = browsers[i].contentTitle.toLowerCase() || "";
var uri = browsers[i].currentURI.spec.toLowerCase();
var host = browsers[i].currentURI.host.toLowerCase();
if (host.indexOf(args) >= 0 || uri == args ||
(special && (title.indexOf(args) >= 0 || uri.indexOf(args) >= 0)))
{
liberator.tabs.remove(liberator.tabs.getTab(i));
removed++;
}
}
}
if (removed > 0)
liberator.echo(removed + " fewer tab(s)");
else
liberator.echoerr("E94: No matching tab for " + args);
}
else // just remove the current tab
liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
},
{ completer: function (filter) { return liberator.completion.buffer(filter); } });
liberator.commands.add(["tab"],
"Execute a command and tell it to output in a new tab",