-
Notifications
You must be signed in to change notification settings - Fork 770
/
windowThemeHandler.js
49 lines (40 loc) · 1.26 KB
/
windowThemeHandler.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
import GMusicTheme from 'gmusic-theme.js';
// Hack the crap out of GMusicTheme
if (!global.isGPM) {
Object.assign(GMusicTheme.prototype, {
_drawLogo: () => {},
_refreshStyleSheet: () => {},
disable: () => {},
enable: () => {},
redrawTheme: () => {},
_injectBackgroundOverlay: () => {},
});
let customColor = Settings.get('themeColor');
let themeType = Settings.get('themeType', 'FULL');
let styles = '';
const hackedGPMTheme = new GMusicTheme();
const customStyle = document.createElement('style');
document.body.appendChild(customStyle);
const redrawCustomStyles = () => {
hackedGPMTheme.updateTheme({
type: themeType,
backHighlight: '#1a1b1d',
foreSecondary: customColor,
});
customStyle.innerHTML = hackedGPMTheme.substituteColors(styles);
};
Emitter.on('settings:change:themeColor', (event, newCustomColor) => {
customColor = newCustomColor;
redrawCustomStyles();
});
Emitter.on('settings:change:themeType', (event, newThemeType) => {
themeType = newThemeType;
redrawCustomStyles();
});
Emitter.on('LoadMainAppCustomStyles', (event, newStyles) => {
styles = newStyles;
redrawCustomStyles();
});
redrawCustomStyles();
Emitter.fire('FetchMainAppCustomStyles');
}