diff --git a/lib/BetterDiscord.js b/lib/BetterDiscord.js
index 1b5a97a1..fd16a544 100644
--- a/lib/BetterDiscord.js
+++ b/lib/BetterDiscord.js
@@ -193,32 +193,74 @@ BetterDiscord.prototype.quit = function(reason) {
var ipcHooked = false;
BetterDiscord.prototype.domReady = function() {
- _this.getUtils().log("Hooked dom-ready");
- if(_updater.LatestVersion > _version) {
- _this.getUtils().execJs('alert("An update for BetterDiscord is available(v'+ _updater.LatestVersion +')! Download the latest version from GitHub!")');
- }
+ if(ipcHooked) {
+ _this.load(true);
+ return;
+ }
+
+ ipcHooked = true;
+ _this.load(false);
+};
+
+BetterDiscord.prototype.load = function(reload) {
+ _this.getUtils().log("Hooked dom-ready");
+
+ if(reload) {
+ _this.getUtils().log("Reloading");
+ }
+
+ if(!reload) {
+ if(_updater.LatestVersion > _version) {
+ _this.getUtils().execJs('alert("An update for BetterDiscord is available(v'+ _updater.LatestVersion +')! Download the latest version from GitHub!")');
+ }
+ }
+
+ //Create loading element
+ _this.getUtils().execJs('var loadingNode = document.createElement("DIV");');
+ _this.getUtils().execJs('loadingNode.innerHTML = \'
BetterDiscord - Loading Libraries : \'');
+ _this.getUtils().execJs('var flex = document.getElementsByClassName("flex-vertical flex-spacer")[0]; flex.appendChild(loadingNode);');
+
+ //Create ipc
+ _this.getUtils().execJs("var betterDiscordIPC = require('ipc');");
+
+
+ if(!reload) {
+ _this.getUtils().log("Hooking ipc async");
+ _ipc.on('asynchronous-message', function(event, arg) { _this.ipcAsyncMessage(event, arg); });
+ _this.getUtils().log("Hooked ipc async");
+ }
+
+ //Inject version
+ _this.getUtils().execJs('var version = "'+_version+'"');
+ //Load jQuery
+ _this.getUtils().updateLoading("Loading Resources(jQuery)", 0, 100);
+ _this.getUtils().injectJavaScriptSync("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", "load-jQueryUI");
+
+};
+
+BetterDiscord.prototype.reload = function() {
+
+ _this.getUtils().log("Reloading...");
+
//Create loading element
_this.getUtils().execJs('var loadingNode = document.createElement("DIV");');
_this.getUtils().execJs('loadingNode.innerHTML = \' BetterDiscord - Loading Libraries : \'');
_this.getUtils().execJs('var flex = document.getElementsByClassName("flex-vertical flex-spacer")[0]; flex.appendChild(loadingNode);');
- //Create ipc
+ //Recreate ipc
_this.getUtils().execJs("var betterDiscordIPC = require('ipc');");
- _this.getUtils().log("Hooking ipc async");
-
- _ipc.on('asynchronous-message', function(event, arg) { _this.ipcAsyncMessage(event, arg); });
-
- _this.getUtils().log("Hooked ipc async");
-
//Inject version
_this.getUtils().execJs('var version = "'+_version+'"');
//Load jQuery
_this.getUtils().updateLoading("Loading Resources(jQuery)", 0, 100);
_this.getUtils().injectJavaScriptSync("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", "load-jQueryUI");
+
};
+var loadCount = 0;
+
BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
var libCount = 9;
@@ -258,7 +300,7 @@ BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
'type': 'json',
'resource': 'Public Servers',
'domain': _updater.CDN,
- 'url': '//' + _repo + '/BetterDiscordApp/' + _hash + 'serverlist.json',
+ 'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/serverlist.json',
'localurl': null,
'message': 'load-emoteData-twitchGlobal',
'cacheable': false,
@@ -341,7 +383,7 @@ BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
}
};
- var loadCount = 0;
+
if(loadUs.hasOwnProperty(arg)) {
loadCount++;
diff --git a/lib/config.json b/lib/config.json
index 6bcc7ac8..3f967dae 100644
--- a/lib/config.json
+++ b/lib/config.json
@@ -1,6 +1,6 @@
{
"Core": {
- "Version": "0.2.2"
+ "Version": "0.2.3"
},
"EmoteModule": {
"Twitch":{
diff --git a/package.json b/package.json
index 7f6f0cf7..825d8bed 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "betterdiscord",
"description": "Better Discord enhances Discord.",
- "version": "0.2.2",
+ "version": "0.2.3",
"homepage": "https://github.com/Jiiks/BetterDiscordApp",
"license": "MIT",
"main": "betterdiscord.js"