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

Commit c9c425a

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

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

resources/app/dom.js

+31
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
11
(function(){
22

3+
var fs = require("fs");
34
var shell = require("shell");
5+
6+
var datapath = process.env.HOME + "/.config/Discord/init.json";
7+
var data;
8+
try{
9+
data = JSON.parse(fs.readFileSync(datapath, 'utf-8'));
10+
} catch(e){
11+
alert("Error loading init.json." + e);
12+
}
13+
14+
var toggleCSS;
15+
toggleCSS = data.useCSS;
16+
//alert("Using CSS?" + toggleCSS);
17+
418
onload = function(){
19+
//alert(csspath);
20+
var customcss = "";
521
var webview = document.getElementById("discord-webview");
22+
if(toggleCSS == true){
23+
var csspath = process.env.HOME + "/.config/Discord/user.css";
24+
fs.readFile(csspath, 'utf-8', function(err,data){
25+
if (err) {alert(err);}
26+
customcss = data;
27+
});
28+
}
29+
webview.addEventListener("dom-ready", function(event){
30+
//webview.openDevTools();
31+
if(customcss != "" && toggleCSS == true){
32+
webview.insertCSS(customcss);
33+
}
34+
});
35+
636
webview.addEventListener("new-window", function(event){
737
console.log(event.url);
838
shell.openExternal(event.url);
939
});
40+
1041
};
1142
})();

0 commit comments

Comments
 (0)