BetterDiscordApp-v1/lib/BetterDiscord.js

643 lines
22 KiB
JavaScript
Raw Normal View History

2015-08-28 09:52:36 +02:00
/* BetterDiscordApp Entry
2016-03-30 03:37:03 +02:00
* Version: 2.2
2015-08-28 09:52:36 +02:00
* Author: Jiiks | http://jiiks.net
* Date: 27/08/2015 - 15:51
2016-03-30 03:37:03 +02:00
* Last Update: 30/03/2016
2015-08-28 09:52:36 +02:00
* https://github.com/Jiiks/BetterDiscordApp
*/
//Imports
2015-10-26 05:12:39 +01:00
var _fs = require("fs");
2015-08-28 09:52:36 +02:00
var _config = require("./config.json");
var _utils = require("./utils");
var _ipc = require('ipc');
2015-08-28 09:52:36 +02:00
var _repo = "Jiiks";
//Beta flag
2015-10-27 21:37:53 +01:00
var _beta = false;
//Local flag
var _local = false;
var _localServer = "http://localhost";
//Variables
var _version;
2015-08-28 09:52:36 +02:00
var _mainWindow;
2015-08-29 21:20:11 +02:00
var _updater;
var _hash;
2015-08-28 09:52:36 +02:00
var _userDefault = { "cache": null };
var _userConfig = _userDefault;
var _cacheExpired = true;
2015-10-26 05:12:39 +01:00
var _cacheDays = 0;
var _dataPath;
//IDE
2015-12-23 10:20:18 +01:00
/*_config = {
"Core": {
2016-03-30 03:37:03 +02:00
"Version": "0.2.7"
}
2015-12-23 10:20:18 +01:00
};*/
//noinspection JSUnresolvedVariable;
2015-10-27 22:14:09 +01:00
var _os = process.platform;
var _userFile;
2015-10-27 22:14:09 +01:00
var _this;
2015-08-28 09:52:36 +02:00
function BetterDiscord(mainWindow) {
_this = this;
2015-08-28 09:52:36 +02:00
_mainWindow = mainWindow;
2015-08-29 21:20:11 +02:00
_version = _config.Core.Version;
2015-08-28 09:52:36 +02:00
_utils = new _utils.Utils(mainWindow);
this.createAndCheckData(this.init);
2015-08-28 09:52:36 +02:00
}
2015-12-15 15:03:39 +01:00
BetterDiscord.prototype.initLoaders = function(){
var os = process.platform;
var _dataPath = os == "win32" ? process.env.APPDATA : os == 'darwin' ? process.env.HOME + '/Library/Preferences' : '/var/local';
_dataPath += "/BetterDiscord/";
if (!_fs.existsSync(_dataPath)) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: Creating BD Dir');
_fs.mkdirSync(_dataPath);
}
2015-12-15 15:03:39 +01:00
if (!_fs.existsSync(_dataPath + "plugins/")) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: Creating Plugins Dir');
_fs.mkdirSync(_dataPath + "plugins/");
}
2015-12-15 15:03:39 +01:00
if (!_fs.existsSync(_dataPath + "themes/")) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: Creating Themes Dir');
_fs.mkdirSync(_dataPath + "themes/");
}
_mainWindow.webContents.executeJavaScript('var themesupport2 = true');
2015-12-15 15:03:39 +01:00
_fs.readdir(_dataPath + "plugins/", function(err, files) {
if (err) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log(err);
return;
}
_mainWindow.webContents.executeJavaScript('var bdplugins = {};');
files.forEach(function(fileName) {
var plugin = _fs.readFileSync(_dataPath + "plugins/" + fileName, 'utf8');
var meta = plugin.split('\n')[0];
if (meta.indexOf('META') < 0) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: ERROR[Plugin META not found in file: ' + fileName + ']');
2015-12-15 15:03:39 +01:00
return;
}
var pluginVar = meta.substring(meta.lastIndexOf('//META') + 6, meta.lastIndexOf('*//'));
var parse = JSON.parse(pluginVar);
var pluginName = parse['name'];
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: Loading Plugin: ' + pluginName);
_mainWindow.webContents.executeJavaScript(plugin);
_mainWindow.webContents.executeJavaScript('(function() { var plugin = new ' + pluginName + '(); bdplugins[plugin.getName()] = { "plugin": plugin, "enabled": false } })();')
2015-12-15 15:03:39 +01:00
});
});
2015-12-15 15:03:39 +01:00
_fs.readdir(_dataPath + 'themes/', function(err, files) {
if (err) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log(err);
return;
}
_mainWindow.webContents.executeJavaScript('var bdthemes = {};');
files.forEach(function(fileName) {
var theme = _fs.readFileSync(_dataPath + 'themes/' + fileName, 'utf8');
var split = theme.split('\n');
var meta = split[0];
if (meta.indexOf('META') < 0) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: ERROR[Theme META not found in file: ' + fileName + ']');
2015-12-15 15:03:39 +01:00
return;
}
var themeVar = meta.substring(meta.lastIndexOf('//META') + 6, meta.lastIndexOf('*//'));
var parse = JSON.parse(themeVar);
var themeName = parse['name'];
var themeAuthor = parse['author'];
var themeDescription = parse['description'];
var themeVersion = parse['version'];
2016-03-30 03:37:03 +02:00
_this.getUtils().log('BetterDiscord: Loading Theme: ' + themeName);
split.splice(0, 1);
theme = split.join('\n');
theme = theme.replace(/(\r\n|\n|\r)/gm, '');
_mainWindow.webContents.executeJavaScript('(function() { bdthemes["' + themeName + '"] = { "enabled": false, "name": "' + themeName + '", "css": "' + escape(theme) + '", "description": "' + themeDescription + '", "author":"' + themeAuthor + '", "version":"' + themeVersion + '" } })();');
2015-12-15 15:03:39 +01:00
});
});
};
2015-08-28 09:52:36 +02:00
BetterDiscord.prototype.getUtils = function() {
return _utils;
};
2015-08-27 14:38:54 +02:00
BetterDiscord.prototype.createAndCheckData = function(callback) {
2015-10-26 05:12:39 +01:00
this.getUtils().log("Checking Cache");
//New data path
//noinspection JSUnresolvedVariable
2015-12-02 14:59:33 +01:00
_dataPath = _os == "win32" ? process.env.APPDATA : _os == 'darwin' ? process.env.HOME + '/Library/Preferences' : '/var/local';
_dataPath += "/BetterDiscord";
_userFile = _dataPath + "/user.json";
2015-10-26 05:12:39 +01:00
try {
//Create data path folder if it doesn't exist
if (!_fs.existsSync(_dataPath)) {
this.getUtils().log("Creating Data Folder @" + _dataPath);
2015-10-26 05:12:39 +01:00
_fs.mkdirSync(_dataPath);
}
//Read user config if it exists
2015-10-26 05:12:39 +01:00
if(_fs.existsSync(_userFile)) {
_userConfig = JSON.parse(_fs.readFileSync(_userFile));
}
//Userfile doesn't exist
2015-10-26 05:12:39 +01:00
if(_userConfig.cache == null) {
_userConfig.cache = new Date();
2015-10-26 05:12:39 +01:00
} else {
var currentDate = new Date();
2015-10-26 05:12:39 +01:00
var cacheDate = new Date(_userConfig.cache);
//Check if cache is expired
if(Math.abs(currentDate.getDate() - cacheDate.getDate()) > _cacheDays) {
_userConfig.cache = currentDate;
} else {
_cacheExpired = false;
2015-10-26 05:12:39 +01:00
}
}
//Write new cache date if expired
if(_cacheExpired) {
this.getUtils().log("Cache Expired or NULL");
_fs.writeFileSync(_userFile, JSON.stringify(_userConfig));
}
callback();
}catch(err) {
//Exit BD
}
};
BetterDiscord.prototype.init = function() {
var self = this;
this.getUtils().log("Initializing");
2015-10-26 05:12:39 +01:00
this.getUtils().log("Getting latest hash");
2015-10-26 05:12:39 +01:00
var branch = _beta ? "beta" : "master";
this.getUtils().log("Using repo: " + _repo + " and branch: " + branch);
//Get the latest commit hash
this.getUtils().download("api.github.com", "/repos/" + _repo + "/BetterDiscordApp/commits/" + branch, function(data) {
try {
_hash = JSON.parse(data).sha;
self.getUtils().execJs("var _hash = " + _hash + ";");
}catch(err) {
self.quit("Failed to load hash");
return;
}
if(typeof(_hash) == "undefined") {
self.quit("Failed to load hash");
return;
}
self.getUtils().log("Hash: "+ _hash);
//Download latest updater
2015-12-18 16:46:03 +01:00
self.getUtils().download("raw.githubusercontent.com", "/" + _repo + "/BetterDiscordApp/" + _hash + "/data/updater.json", function(data) {
try {
_updater = JSON.parse(data);
}catch(err) {
self.quit("Failed to load updater data");
return;
}
if(typeof(_updater) == "undefined") {
self.quit("Failed to load updater data");
return;
}
self.getUtils().log("Latest Versions: " + _updater.LatestVersion);
self.getUtils().log("Using CDN: " + _updater.CDN);
self.getUtils().log("Starting up");
2016-03-30 03:37:03 +02:00
self.updateData();
self.start();
});
2015-08-29 21:20:11 +02:00
});
2015-10-26 05:12:39 +01:00
};
2015-08-27 14:38:54 +02:00
BetterDiscord.prototype.start = function() {
_this.getUtils().log("Hooking dom-ready");
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) {
2016-03-30 03:37:03 +02:00
_this.getUtils().log("BetterDiscord ERR: " + reason);
};
var ipcHooked = false;
var _domHooked = false;
BetterDiscord.prototype.domReady = function() {
_domHooked = true;
if(ipcHooked) {
_this.load(true);
return;
}
ipcHooked = true;
_this.load(false);
};
2015-08-29 21:20:11 +02:00
BetterDiscord.prototype.load = function(reload) {
_this.getUtils().log("Hooked dom-ready");
_this.initLoaders();
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 = \' <div style="height:30px;width:100%;background:#282B30;"><div style="padding-right:10px; float:right"> <span id="bd-status" style="line-height:30px;color:#E8E8E8;">BetterDiscord - Loading Libraries : </span><progress id="bd-pbar" value="10" max="100"></progress></div></div> \'');
_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+'"');
2015-12-13 13:40:58 +01:00
//Inject cdn
_this.getUtils().execJs('var bdcdn = "' + _updater.CDN + '";');
//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;
2016-03-30 03:37:03 +02:00
var libCount;
var loadUs;
2016-03-30 03:37:03 +02:00
BetterDiscord.prototype.updateData = function() {
libCount = 9;
loadUs = {
'load-jQueryUI': {
'type': 'javascript',
'resource': 'jQueryUI',
'domain': 'cdnjs.cloudflare.com',
'url': '//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js',
'localurl': null,
'message': 'load-mainCSS',
'cacheable': false,
'variable': null
},
'load-mainCSS': {
'type': 'css',
'resource': 'Main CSS',
'domain': _updater.CDN,
2015-11-30 23:57:59 +01:00
'url': '//' + _updater.CDN + '/' + _repo + '/BetterDiscordApp/' + _hash + '/css/main.min.css',
2015-12-10 04:01:24 +01:00
'localurl': _localServer + '/BetterDiscordApp/css/main.css',
'message': 'load-mainJS',
'cacheable': false,
'variable': null
},
'load-mainJS': {
'type': 'javascript',
'resource': 'Main JS',
'domain': _updater.CDN,
2015-11-30 23:57:59 +01:00
'url': '//' + _updater.CDN + '/' + _repo + '/BetterDiscordApp/' + _hash + '/js/main.min.js',
2015-12-10 04:01:24 +01:00
'localurl': _localServer + '/BetterDiscordApp/js/main.js',
'message': 'load-publicServers',
'cacheable': false,
'variable': null
},
'load-publicServers': {
'type': 'json',
'resource': 'Public Servers',
'domain': _updater.CDN,
2015-12-18 16:43:44 +01:00
'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/data/serverlist.json',
'localurl': null,
'message': 'load-emoteData-twitchGlobal',
'cacheable': false,
'variable': 'publicServers'
},
'load-emoteData-twitchGlobal': {
'type': 'emotedata',
'resource': 'Twitch Global Emotedata',
2016-02-10 03:09:44 +01:00
'domain': 'twitchemotes.com',
2016-02-10 03:04:44 +01:00
'url': '/api_cache/v2/global.json',
'localurl': null,
'message': 'load-emoteData-twitchSub',
'cacheable': true,
'variable': 'emotesTwitch',
'localpath': _dataPath + "/emotes_twitch_global.json",
'encoding': "utf8",
2016-02-10 03:04:44 +01:00
'https': true,
2016-03-30 03:37:03 +02:00
'parse': false,
'specialparser': 0,
'fallback': 'load-emoteData-twitchGlobal-fallback',
'self': 'load-emoteData-twitchGlobal'
},
'load-emoteData-twitchGlobal-fallback': {
'type': 'emotedata',
'resource': 'Twitch Global Emotedata',
'domain': _updater.CDN,
'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/data/emotedata_twitch_global.json',
'localurl': null,
'message': 'load-emoteData-twitchSub',
'cacheable': true,
'variable': 'emotesTwitch',
'localpath': _dataPath + "/emotes_twitch_global.json",
'encoding': "utf8",
'https': true,
'parse': false,
'specialparser': 0,
'fallback': 'load-emoteData-twitchSub',
'self': 'load-emoteData-twitchGlobal-fallback'
},
'load-emoteData-twitchSub': {
'type': 'emotedata',
'resource': 'Twitch Subscriber Emotedata',
2016-02-10 03:09:44 +01:00
'domain': 'twitchemotes.com',
2016-02-10 03:04:44 +01:00
'url': '/api_cache/v2/subscriber.json',
'localurl': null,
'message': 'load-emoteData-ffz',
'cacheable': true,
'variable': 'subEmotesTwitch',
'localpath': _dataPath + "/emotes_twitch_subscriber.json",
'encoding': "utf8",
2016-02-10 03:04:44 +01:00
'https': true,
'parse': true,
2016-03-30 03:37:03 +02:00
'specialparser': 1,
'fallback': 'load-emoteData-twitchSub-fallback',
'self': 'load-emoteData-twitchSub'
},
'load-emoteData-twitchSub-fallback': {
'type': 'emotedata',
'resource': 'Twitch Subscriber Emotedata',
'domain': _updater.CDN,
'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/data/emotedata_twitch_subscriber.json',
'localurl': null,
'message': 'load-emoteData-ffz',
'cacheable': true,
'variable': 'subEmotesTwitch',
'localpath': _dataPath + "/emotes_twitch_subscriber.json",
'encoding': "utf8",
'https': true,
'parse': true,
'specialparser': 1,
'fallback': 'load-emoteData-ffz',
'self': 'load-emoteData-twitchSub-fallback'
},
'load-emoteData-ffz': {
'type': 'emotedata',
'resource': 'FrankerFaceZ Emotedata',
'domain': _updater.CDN,
2015-12-18 16:43:44 +01:00
'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/data/emotedata_ffz.json',
'localurl': null,
'message': 'load-emoteData-bttv',
'cacheable': true,
'variable': 'emotesFfz',
'localpath': _dataPath + "/emotes_ffz.json",
'encoding': "utf8",
'https': true,
'parse': true,
2016-03-30 03:37:03 +02:00
'specialparser': 2,
'fallback': 'load-emoteData-bttv',
'self': 'load-emoteData-ffz'
},
'load-emoteData-bttv': {
'type': 'emotedata',
'resource': 'BTTV Emotedata',
'domain': 'api.betterttv.net',
'url': '/emotes',
'localurl': null,
2015-12-10 04:01:24 +01:00
'message': 'load-emoteData-bttv-2',
'cacheable': true,
'variable': 'emotesBTTV',
'localpath': _dataPath + "/emotes_bttv.json",
'encoding': "utf8",
'https': true,
'parse': false,
2016-03-30 03:37:03 +02:00
'specialparser': 3,
'fallback': 'load-emoteData-bttv-2',
'self': 'load-emoteData-bttv'
2015-12-10 04:01:24 +01:00
},
'load-emoteData-bttv-2': {
'type': 'emotedata',
'resource': 'BTTV Emotedata',
'domain': _updater.CDN,
2015-12-18 16:43:44 +01:00
'url': '/' + _repo + '/BetterDiscordApp/' + _hash + '/data/emotedata_bttv.json',
2015-12-10 04:01:24 +01:00
'localurl': null,
'message': 'start-bd',
'cacheable': true,
'variable': 'emotesBTTV2',
'localpath': _dataPath + "/emotes_bttv_2.json",
'encoding': "utf8",
'https': true,
'parse': false,
2016-03-30 03:37:03 +02:00
'specialparser': 4,
'fallback': 'start-bd',
'self': 'load-emoteData-bttv-2'
2015-10-26 05:12:39 +01:00
}
};
2016-03-30 03:37:03 +02:00
}
2015-08-29 21:20:11 +02:00
2016-03-30 03:37:03 +02:00
BetterDiscord.prototype.ipcAsyncMessage = function(event, arg) {
2015-08-29 21:20:11 +02:00
if(loadUs.hasOwnProperty(arg)) {
loadCount++;
var loadMe = loadUs[arg];
_this.getUtils().updateLoading("Loading Resources (" + loadMe.resource + ")", loadCount / libCount * 100, 100);
var url = loadMe.url;
if(_local && loadMe.localurl != null) {
url = loadMe.localurl;
}
if(loadMe.type == 'javascript') {
_this.getUtils().injectJavaScriptSync(url, loadMe.message);
}else if(loadMe.type == 'css') {
_this.getUtils().injectStylesheetSync(url, loadMe.message);
}else if(loadMe.type == 'json') {
_this.getUtils().download(loadMe.domain, loadMe.url, function(data) {
_this.getUtils().execJs('var ' + loadMe.variable + ' = ' + data + ';');
_this.getUtils().sendIcpAsync(loadMe.message);
});
}else if(loadMe.type == 'emotedata') {
2016-03-30 03:37:03 +02:00
if(loadMe.variable != "emotesTwitch") {
_this.getUtils().execJs('var ' + loadMe.variable + ' = {};');//jic
}
var exists = _fs.existsSync(loadMe.localpath);
if(exists && !_cacheExpired && loadMe.cacheable) {
2016-03-30 03:37:03 +02:00
_this.loadLocalEData(loadMe);
//_this.injectEmoteData(loadMe, _fs.readFileSync(loadMe.localpath, loadMe.encoding));
} else {
2016-03-30 03:37:03 +02:00
_this.loadRemoteEData(loadMe);
2015-10-26 05:12:39 +01:00
}
}
}
if(arg == "start-bd") {
2016-03-30 03:37:03 +02:00
_this.getUtils().saveLogs(_dataPath);
_this.getUtils().updateLoading("Starting Up", 100, 100);
_this.getUtils().execJs('var mainCore; var startBda = function() { mainCore = new Core(); mainCore.init(); }; startBda();');
//Remove loading node
setTimeout(function() {
_this.getUtils().execJs('$("#bd-status").parent().parent().hide();');
}, 2000);
}
};
2016-03-30 03:37:03 +02:00
BetterDiscord.prototype.loadRemoteEData = function(loadMe) {
_this.getUtils().log("Downloading " + loadMe.resource + " from " + loadMe.domain + loadMe.url );
if(loadMe.https) {
_this.getUtils().download(loadMe.domain, loadMe.url, function(data) {
var parsedEmoteData = _this.parseEmoteData(loadMe, data);
if(parsedEmoteData == null) {
_this.getUtils().sendIcpAsync(loadMe.fallback);
return true;
}
_this.saveEmoteData(loadMe, parsedEmoteData);
_this.injectEmoteData(loadMe, parsedEmoteData);
});
return true;
}
_this.getUtils().downloadHttp(loadMe.url, function(data) {
var parsedEmoteData = _this.parseEmoteData(loadMe, data);
_this.saveEmoteData(loadMe, parsedEmoteData);
_this.injectEmoteData(loadMe, parsedEmoteData);
});
};
BetterDiscord.prototype.loadLocalEData = function(loadMe) {
_this.getUtils().log("Reading " + loadMe.resource + " from file");
var data = _fs.readFileSync(loadMe.localpath, loadMe.encoding);
if(_this.testJSON(loadMe, data)) {
_this.injectEmoteData(loadMe, data);
} else {
_this.getUtils().log("Deleting cached file " + loadMe.resource);
_fs.unlinkSync(loadMe.localpath);
_this.getUtils().sendIcpAsync(loadMe.self);
}
};
BetterDiscord.prototype.testJSON = function(loadMe, data) {
_this.getUtils().log("Validating " + loadMe.resource);
try {
var json = JSON.parse(data);
_this.getUtils().log(loadMe.resource + " is valid");
return true;
}catch(err) {
_this.getUtils().log(loadMe.resource + " is invalid");
return false;
}
};
BetterDiscord.prototype.parseEmoteData = function(loadMe, emoteData) {
_this.getUtils().log("Parsing: " + loadMe.resource);
var returnData;
switch(loadMe.specialparser) {
case 0: //Twitch Global Emotes
2016-03-30 03:37:03 +02:00
//returnData = emoteData.replace(/\$/g, "\\$").replace(/'/g, "\\'").replace(/"/g, "\\\""); We don't need this anymore
return emoteData;
break;
case 1: //Twitch Subscriber Emotes
returnData = {};
2016-03-30 03:37:03 +02:00
if(!_this.testJSON(loadMe, emoteData)) {
return null;
}
emoteData = JSON.parse(emoteData);
2016-03-30 03:37:03 +02:00
var channels = emoteData["channels"];
for(var channel in channels) {
var emotes = channels[channel]["emotes"];
for(var i = 0 ; i < emotes.length ; i++) {
var code = emotes[i]["code"];
var id = emotes[i]["image_id"];
returnData[code] = id;
}
}
returnData = JSON.stringify(returnData);
break;
case 2: //FFZ Emotes
returnData = emoteData;
break;
case 3: //BTTV Emotes
returnData = {};
2016-03-30 03:37:03 +02:00
if(!_this.testJSON(loadMe, emoteData)) {
return null;
}
emoteData = JSON.parse(emoteData);
for(var emote in emoteData.emotes) {
emote = emoteData.emotes[emote];
var url = emote.url;
var code = emote.regex;
returnData[code] = url;
}
returnData = JSON.stringify(returnData);
break;
2015-12-10 04:01:24 +01:00
case 4:
returnData = emoteData;
break;
}
return returnData;
};
BetterDiscord.prototype.saveEmoteData = function(loadMe, emoteData) {
_fs.writeFileSync(loadMe.localpath, emoteData, loadMe.encoding);
};
BetterDiscord.prototype.injectEmoteData = function(loadMe, emoteData) {
2016-03-30 03:37:03 +02:00
if(emoteData != null) {
if(loadMe.parse) {
_this.getUtils().execJs('var ' + loadMe.variable + ' = JSON.parse(\'' + emoteData + '\');');
} else {
_this.getUtils().execJs('var ' + loadMe.variable + ' = ' + emoteData + ';');
}
}
_this.getUtils().sendIcpAsync(loadMe.message);
2015-10-26 05:12:39 +01:00
};
2015-08-28 09:52:36 +02:00
2016-03-30 03:37:03 +02:00
exports.BetterDiscord = BetterDiscord;