This repository was archived by the owner on Jun 26, 2018. It is now read-only.
Commit c9c425a 1 parent efed8be commit c9c425a Copy full SHA for c9c425a
File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1
1
( function ( ) {
2
2
3
+ var fs = require ( "fs" ) ;
3
4
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
+
4
18
onload = function ( ) {
19
+ //alert(csspath);
20
+ var customcss = "" ;
5
21
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
+
6
36
webview . addEventListener ( "new-window" , function ( event ) {
7
37
console . log ( event . url ) ;
8
38
shell . openExternal ( event . url ) ;
9
39
} ) ;
40
+
10
41
} ;
11
42
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments