-
Notifications
You must be signed in to change notification settings - Fork 9
/
mute.js
38 lines (29 loc) · 1.01 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
(function muteBtn() {
// Note: volumeButtons.js provides more functionality
// requires menuButton.js
//
// Adds 'mute' toggle button to UI Bar
'use strict';
/* globals l10nStrings, scUtils, storage */
let mute = storage.get('mute') === 'true';
function renderMute() {
storage.get('mute', mute.toString());
document.documentElement.classList.toggle('mute', mute);
jQuery.wiki(`<<masteraudio ${mute ? 'mute' : 'unmute'}>>`); // use engine API instead of undocumented access
}
function handler() {
mute = !mute;
renderMute();
}
const { style } = scUtils.createHandlerButton(l10nStrings.uiBarMute || 'Sound', '\\e843\\00a0', 'mute', handler);
const styleId = style.attr('id').replace(/-style$/, '');
style.text(`
#menu-core #${styleId} a::before {
content: '\\e843\\00a0';
}
.mute #menu-core #${styleId} a::before {
content: '\\e842\\00a0';
}
`);
renderMute();
}());