Skip to content
This repository was archived by the owner on Jun 26, 2018. It is now read-only.

Commit 0825c91

Browse files
committed
Added ability to use Custom CSS.
1 parent c9c425a commit 0825c91

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

resources/app/main.js

+30-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ try {
1717
catch(e){
1818
data = {
1919
"bounds": {"x":100, "y":100, "width":1024,"height":768},
20-
"minTray":false
20+
"minTray":false,
21+
"useCSS":false
2122
};
2223
}
2324

2425
var menu = new Menu();
2526
var minToTray;
27+
var useCustomCSS;
2628
minToTray = data.minTray;
27-
29+
useCustomCSS = data.useCSS;
2830
var updateReady = false;
2931
var quitForReal = false; // Dirty
3032

@@ -69,8 +71,9 @@ app.on('ready', function() {
6971
//Save settings when app is closed.
7072
mainWindow.on('close', function(){
7173
var data = {
72-
bounds: mainWindow.getBounds(),
73-
minTray: minToTray
74+
bounds: mainWindow.getBounds(),
75+
minTray: minToTray,
76+
useCSS: useCustomCSS
7477
};
7578
fs.writeFileSync(initPath, JSON.stringify(data));
7679
});
@@ -104,6 +107,25 @@ app.on('ready', function() {
104107
}
105108
});
106109

110+
//Toggle CSS (Only works on some OSs?)
111+
var toggleCSS = new MenuItem({
112+
label: 'Use Custom CSS',
113+
type: 'checkbox',
114+
checked: useCustomCSS,
115+
click: function() {
116+
if(toggleCSS.checked == true){
117+
useCustomCSS = true;
118+
console.log("Disabled useCustomCSS");
119+
} else if (toggleCSS.checked == false) {
120+
useCustomCSS = false;
121+
console.log("Enabled useCustomCSS");
122+
}
123+
124+
toggleCSS.checked = useCustomCSS;
125+
126+
}
127+
});
128+
107129
mainWindow.on('close', function(event) {
108130
if(minToTray && !quitForReal){
109131
event.preventDefault();
@@ -122,6 +144,7 @@ app.on('ready', function() {
122144
menu.append(new MenuItem({ label: 'Refresh Discord', type: 'normal', click: function(){ mainWindow.reload(); } }));
123145
menu.append(new MenuItem({ type: 'separator' }));
124146
menu.append(disMinButton);
147+
menu.append(toggleCSS);
125148
menu.append(new MenuItem({ type: 'separator' }));
126149
menu.append(new MenuItem({ label: 'Quit Discord', type: 'normal', click: function() { quitForReal = true; app.quit(); } }));
127150

@@ -153,5 +176,8 @@ app.on('ready', function() {
153176
globalShortcut.unregister('ctrl+r');
154177
});
155178

179+
mainWindow.webContents.on('will-navigate', function(event){
180+
event.preventDefault();
181+
});
156182

157183
});

0 commit comments

Comments
 (0)