-
Notifications
You must be signed in to change notification settings - Fork 7
/
nightMode.js
50 lines (29 loc) · 1022 Bytes
/
nightMode.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
/****************************************************************************
* nightMode.js
* openacousticdevices.info
* December 2019
*****************************************************************************/
'use strict';
const {app} = require('@electron/remote');
let nightMode = false;
exports.isEnabled = () => {
return nightMode;
};
function setNightMode (nm) {
nightMode = nm;
const oldLink = document.getElementById('uiCSS');
const newLink = document.createElement('link');
newLink.setAttribute('id', 'uiCSS');
newLink.setAttribute('rel', 'stylesheet');
newLink.setAttribute('type', 'text/css');
if (nightMode) {
newLink.setAttribute('href', app.getAppPath() + '/uiNight.css');
} else {
newLink.setAttribute('href', app.getAppPath() + '/ui.css');
}
document.getElementsByTagName('head').item(0).replaceChild(newLink, oldLink);
}
exports.setNightMode = setNightMode;
exports.toggle = () => {
setNightMode(!nightMode);
};