-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathmute.js
59 lines (53 loc) · 1.25 KB
/
mute.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* A plugin to mute a tab
*
* Christopher Grossack, 2016
*
* website: https://github.com/HallaSurvivor
* email: [email protected]
*
* version 0.3
*
* Commands:
*
* mute [n]
* mute tab n (current tab by default)
*
* == CHANGELOG ==
* version 0.2
* Added INFO section.
*
* version 0.3
* Made the code more intuitive in tab selection
*
* Added completion with tab labels
*
* Removed INFO section, as it introduced an unfixable bug
*
*/
function _completer(context)
{
var allTabs = gBrowser.visibleTabs;
// Remember, vimperator indexes from 1.
var indices = allTabs.map(function(tab) { return allTabs.indexOf(tab) + 1 });
var labels = allTabs.map(function(tab) { return tab.label });
var indicesAndHints = indices.map(function(e, i) { return [indices[i], labels[i]] });
context.completions = indicesAndHints;
}
commands.add(
["mute"],
"Mute a tab. (Mutes current tab by default)",
function(n)
{
if(!n || n <= 0 || n > config.tabbrowser.visibleTabs.length)
{
window.gBrowser.mCurrentTab.toggleMuteAudio();
}
else
{
// JS indexes from 0, vimperator indexes from 1
window.gBrowser.visibleTabs[n - 1].toggleMuteAudio();
}
},
{ argCount: '1', completer: _completer }
);