hotchpotch (owner)

Revisions

gist: 81090 Download_button fork
public
Public Clone URL: git://gist.github.com/81090.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
);