Move loaders to same dom event and added a failsafe dom hook
This commit is contained in:
parent
105a04a000
commit
0fdfcaa3e8
|
@ -1,5 +1,5 @@
|
||||||
/* BetterDiscordApp Entry
|
/* BetterDiscordApp Entry
|
||||||
* Version: 2.0
|
* Version: 2.1
|
||||||
* Author: Jiiks | http://jiiks.net
|
* Author: Jiiks | http://jiiks.net
|
||||||
* Date: 27/08/2015 - 15:51
|
* Date: 27/08/2015 - 15:51
|
||||||
* Last Update: 30/11/2015 - 21:41
|
* Last Update: 30/11/2015 - 21:41
|
||||||
|
@ -12,45 +12,16 @@ var _config = require("./config.json");
|
||||||
var _utils = require("./utils");
|
var _utils = require("./utils");
|
||||||
var _ipc = require('ipc');
|
var _ipc = require('ipc');
|
||||||
|
|
||||||
//For IDE
|
|
||||||
/*_config = {
|
|
||||||
"Core": {
|
|
||||||
"Version": "0.2.0"
|
|
||||||
},
|
|
||||||
"EmoteModule": {
|
|
||||||
"Twitch":{
|
|
||||||
"EmoteData": "emotedata_twitch.json",
|
|
||||||
"EmoteUrlStart": "https://static-cdn.jtvnw.net/emoticons/v1/",
|
|
||||||
"EmoteUrlEnd": "/1.0"
|
|
||||||
},
|
|
||||||
"FrankerFaceZ": {
|
|
||||||
"EmoteData": "emotedata_ffz.json",
|
|
||||||
"EmoteUrlStart": "https://cdn.frankerfacez.com/emoticon/",
|
|
||||||
"EmoteUrlEnd": "/1"
|
|
||||||
},
|
|
||||||
"BetterTTV": {
|
|
||||||
"EmoteData": "emotedata_bttv.json",
|
|
||||||
"EmoteUrlStart": "",
|
|
||||||
"EmoteUrlEnd": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};*/
|
|
||||||
|
|
||||||
var _repo = "Jiiks";
|
var _repo = "Jiiks";
|
||||||
|
|
||||||
//Beta flag
|
//Beta flag
|
||||||
var _beta = false;
|
var _beta = false;
|
||||||
var _alerts = true;
|
|
||||||
//Local flag
|
//Local flag
|
||||||
var _local = false;
|
var _local = false;
|
||||||
var _localServer = "http://localhost";
|
var _localServer = "http://localhost";
|
||||||
//Please note that you must either use https or set web-security to false when using local server
|
|
||||||
//Everything is loaded from _localServer/BetterDiscordApp/
|
|
||||||
//For css use: _localServer/BetterDiscordApp/css/main.css
|
|
||||||
//For js use: _localServer/BetterDiscordApp/js/main.js
|
|
||||||
|
|
||||||
//Variables
|
//Variables
|
||||||
var _version
|
var _version;
|
||||||
var _mainWindow;
|
var _mainWindow;
|
||||||
var _updater;
|
var _updater;
|
||||||
var _hash;
|
var _hash;
|
||||||
|
@ -62,6 +33,13 @@ var _cacheDays = 0;
|
||||||
|
|
||||||
var _dataPath;
|
var _dataPath;
|
||||||
|
|
||||||
|
//IDE
|
||||||
|
_config = {
|
||||||
|
"Core": {
|
||||||
|
"Version": "0.2.5"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//noinspection JSUnresolvedVariable;
|
//noinspection JSUnresolvedVariable;
|
||||||
var _os = process.platform;
|
var _os = process.platform;
|
||||||
var _userFile;
|
var _userFile;
|
||||||
|
@ -70,7 +48,6 @@ var _this;
|
||||||
function BetterDiscord(mainWindow) {
|
function BetterDiscord(mainWindow) {
|
||||||
_this = this;
|
_this = this;
|
||||||
_mainWindow = mainWindow;
|
_mainWindow = mainWindow;
|
||||||
this.initLoaders();
|
|
||||||
_version = _config.Core.Version;
|
_version = _config.Core.Version;
|
||||||
_utils = new _utils.Utils(mainWindow);
|
_utils = new _utils.Utils(mainWindow);
|
||||||
|
|
||||||
|
@ -82,7 +59,6 @@ BetterDiscord.prototype.initLoaders = function(){
|
||||||
var _dataPath = os == "win32" ? process.env.APPDATA : os == 'darwin' ? process.env.HOME + '/Library/Preferences' : '/var/local';
|
var _dataPath = os == "win32" ? process.env.APPDATA : os == 'darwin' ? process.env.HOME + '/Library/Preferences' : '/var/local';
|
||||||
_dataPath += "/BetterDiscord/";
|
_dataPath += "/BetterDiscord/";
|
||||||
|
|
||||||
_mainWindow.webContents.on('dom-ready', function() {
|
|
||||||
if (!_fs.existsSync(_dataPath)) {
|
if (!_fs.existsSync(_dataPath)) {
|
||||||
console.log('BetterDiscord: Creating BD Dir');
|
console.log('BetterDiscord: Creating BD Dir');
|
||||||
_fs.mkdirSync(_dataPath);
|
_fs.mkdirSync(_dataPath);
|
||||||
|
@ -148,12 +124,11 @@ BetterDiscord.prototype.initLoaders = function(){
|
||||||
_mainWindow.webContents.executeJavaScript('(function() { bdthemes["' + themeName + '"] = { "enabled": false, "name": "' + themeName + '", "css": "' + escape(theme) + '", "description": "' + themeDescription + '", "author":"' + themeAuthor + '", "version":"' + themeVersion + '" } })();');
|
_mainWindow.webContents.executeJavaScript('(function() { bdthemes["' + themeName + '"] = { "enabled": false, "name": "' + themeName + '", "css": "' + escape(theme) + '", "description": "' + themeDescription + '", "author":"' + themeAuthor + '", "version":"' + themeVersion + '" } })();');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BetterDiscord.prototype.getUtils = function() {
|
BetterDiscord.prototype.getUtils = function() {
|
||||||
return _utils;
|
return _utils;
|
||||||
}
|
};
|
||||||
|
|
||||||
BetterDiscord.prototype.createAndCheckData = function(callback) {
|
BetterDiscord.prototype.createAndCheckData = function(callback) {
|
||||||
|
|
||||||
|
@ -258,7 +233,9 @@ BetterDiscord.prototype.init = function() {
|
||||||
|
|
||||||
BetterDiscord.prototype.start = function() {
|
BetterDiscord.prototype.start = function() {
|
||||||
_this.getUtils().log("Hooking dom-ready");
|
_this.getUtils().log("Hooking dom-ready");
|
||||||
_this.getUtils().getWebContents().on('dom-ready', function() { _this.domReady(); });
|
var webContents = _this.getUtils().getWebContents();
|
||||||
|
webContents.on('dom-ready', function() { _this.domReady(); });
|
||||||
|
webContents.on("did-finish-loading", function() { if(!_domHooked) { _this.getUtils().log("Failsafe"); _this.domReady(); } });
|
||||||
};
|
};
|
||||||
|
|
||||||
BetterDiscord.prototype.quit = function(reason) {
|
BetterDiscord.prototype.quit = function(reason) {
|
||||||
|
@ -267,8 +244,12 @@ BetterDiscord.prototype.quit = function(reason) {
|
||||||
|
|
||||||
var ipcHooked = false;
|
var ipcHooked = false;
|
||||||
|
|
||||||
|
var _domHooked = false;
|
||||||
|
|
||||||
BetterDiscord.prototype.domReady = function() {
|
BetterDiscord.prototype.domReady = function() {
|
||||||
|
|
||||||
|
_domHooked = true;
|
||||||
|
|
||||||
if(ipcHooked) {
|
if(ipcHooked) {
|
||||||
_this.load(true);
|
_this.load(true);
|
||||||
return;
|
return;
|
||||||
|
@ -281,6 +262,8 @@ BetterDiscord.prototype.domReady = function() {
|
||||||
BetterDiscord.prototype.load = function(reload) {
|
BetterDiscord.prototype.load = function(reload) {
|
||||||
_this.getUtils().log("Hooked dom-ready");
|
_this.getUtils().log("Hooked dom-ready");
|
||||||
|
|
||||||
|
_this.initLoaders();
|
||||||
|
|
||||||
if(reload) {
|
if(reload) {
|
||||||
_this.getUtils().log("Reloading");
|
_this.getUtils().log("Reloading");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue