diff --git a/.gitignore b/.gitignore index bda221d..4c9d65e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ node_modules /*.jiiks Installers/dotNet/bin/ Installers/dotNet/packages/ -Installers/dotNet/dlls/ \ No newline at end of file +Installers/dotNet/dlls/ +v2/dist/vendor/ +v2/lib/static.js \ No newline at end of file diff --git a/v2/lib/core.js b/v2/lib/core.js index 6fa5a05..5191758 100644 --- a/v2/lib/core.js +++ b/v2/lib/core.js @@ -29,9 +29,25 @@ const _defaults = { emotesEnabled: true }; +const _resources = { + "mainjs": { + "path": "js", + "filename": "main.js", + "var": "window.BetterDiscord" + }, + "jQuery": { + "path": "vendor", + "filename": "jquery-2.2.4.min.js", + "var": "window.BD.$ = window.BD.jQuery" + } +}; + +var _self; + class Core { constructor(args) { + _self = this; this.continue = true; _logger.log(`v${this.__version} Loading - OS: ${_os.platform()}`); this.initConfig(args.cfg); @@ -64,7 +80,10 @@ class Core { } domReady() { - + for(var key in _resources) { + var resource = _resources[key]; + _utils.requireJs(`${_cfg.dataPath}/${resource.path}/${resource.filename}`, resource.var, _self.mainWindow); + } } exit(reason, severity) { diff --git a/v2/lib/utils.js b/v2/lib/utils.js index e8fef05..4da2c9b 100644 --- a/v2/lib/utils.js +++ b/v2/lib/utils.js @@ -42,11 +42,16 @@ class Utils { }); } + requireJs(file, varstring, _window) { + _logger.log(`Injecting file: ${file}`); + _window.webContents.executeJavaScript(`${varstring} = require("${file}");`); + } + //Returns a datestring: [DD/MM/YYYY - HH:MM:SS] get dateString() { var d = new Date(); - return `${("00" + (d.getDate() + 1)).slice(-2)}/` + + return `${("00" + (d.getDate())).slice(-2)}/` + `${("00" + d.getMonth()).slice(-2)}/` + `${d.getFullYear()} - ` + `${("00" + d.getHours()).slice(-2)}:` +