module conversion
This commit is contained in:
parent
6b920b67b1
commit
6069c05d0d
|
@ -1,19 +0,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": "",
|
||||
"EmoteUrlStart": "",
|
||||
"EmoteUrlEnd": ""
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/* BetterDiscordApp Helper functions
|
||||
* Version: 1.0
|
||||
* Author: Jiiks | http://jiiks.net
|
||||
* Date: 25/08/2015 - 09:19
|
||||
* https://github.com/Jiiks/BetterDiscordApp
|
||||
*/
|
||||
|
||||
var https = require('https');
|
||||
|
||||
var _mainWindow;
|
||||
|
||||
function Helper(mainWindow) {
|
||||
_mainWindow = mainWindow;
|
||||
}
|
||||
|
||||
//get app mainwindow
|
||||
function getMainWindow() {
|
||||
return _mainWindow;
|
||||
}
|
||||
|
||||
//Download using https
|
||||
Helper.prototype.download = function(url, callback) {
|
||||
https.get(url, function(res) {
|
||||
var data = "";
|
||||
res.on('data', function (chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
res.on("end", function() {
|
||||
callback(data);
|
||||
});
|
||||
}).on("error", function() {
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
//Get webcontents
|
||||
Helper.prototype.getWeb = function() {
|
||||
return getMainWindow().webContents;
|
||||
}
|
||||
|
||||
//Log
|
||||
Helper.prototype.log = function(message) {
|
||||
this.execJs('console.log("BetterDiscord: ' + message + '");');
|
||||
}
|
||||
//Warn
|
||||
Helper.prototype.warn = function(message) {
|
||||
this.execJs('console.warn("BetterDiscord: ' + message + '");');
|
||||
}
|
||||
//Error
|
||||
Helper.prototype.error = function(message) {
|
||||
this.execJs('console.error("BetterDiscord: ' + message + '");');
|
||||
}
|
||||
|
||||
//Execute javascript
|
||||
Helper.prototype.execJs = function(js) {
|
||||
this.getWeb().executeJavaScript(js);
|
||||
}
|
||||
|
||||
//Inject variable to first element by tag
|
||||
Helper.prototype.injectToElementByTag = function(element, js, varname) {
|
||||
this.execJs(js + " " + 'document.getElementsByTagName("'+element+'")[0].appendChild('+varname+')');
|
||||
}
|
||||
|
||||
//Injects a stylesheet from url to head as internal style
|
||||
Helper.prototype.injectStylesheet = function(url) {
|
||||
var self = this;
|
||||
this.download(url, function(data) {
|
||||
var js = 'var style = document.createElement("style"); style.type = "text/css"; style.innerHTML = "'+data+'";';
|
||||
self.injectToElementByTag("head", js, "style");
|
||||
});
|
||||
}
|
||||
|
||||
Helper.prototype.headStyleSheet = function(url) {
|
||||
this.execJs('(function() { var stylesheet = document.createElement("link"); stylesheet.type = "text/css"; document.getElementsByTagName("head")[0].appendChild(stylesheet); stylesheet.href = "'+url+'" })();')
|
||||
}
|
||||
|
||||
Helper.prototype.injectJavaScript = function(url) {
|
||||
this.execJs('(function() { var script = document.createElement("script"); script.type = "text/javascript"; document.getElementsByTagName("body")[0].appendChild(script); script.src = "'+url+'"; })();');
|
||||
}
|
||||
|
||||
exports.Helper = Helper;
|
|
@ -1,39 +0,0 @@
|
|||
/* BetterDiscordApp Main
|
||||
* Version: 1.0
|
||||
* Author: Jiiks | http://jiiks.net
|
||||
* Date: 25/08/2015 - 08:12
|
||||
* Last Update: 25/08/2015 - 17:38
|
||||
* https://github.com/Jiiks/BetterDiscordApp
|
||||
*/
|
||||
|
||||
var _helpers = require('./helper.js');
|
||||
var _emoteModule = require('./modules/EmoteModule.js');
|
||||
var _config = require('./config.json');
|
||||
var _helper;
|
||||
var _mainWindow;
|
||||
var _version = "1.0.0";
|
||||
|
||||
function BetterDiscordApp(mainWindow) {
|
||||
_mainWindow = mainWindow;
|
||||
_helper = new _helpers.Helper(mainWindow);
|
||||
_helper.getWeb().on('did-finish-load', function() { init(); });
|
||||
_helper.getWeb().on('dom-ready', function() {
|
||||
|
||||
_helper.injectJavaScript("//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"); //jquery
|
||||
//TODO make this proper
|
||||
setTimeout(function() { //Temporary timer for letting jquery fully load
|
||||
//TODO LOAD COMMIT HASH, BOTH CSS AND JS WILL HAVE THE SAME COMMIT
|
||||
//Load Main Stylesheet. Note that if you want to load stylesheets, escape them properly.
|
||||
_helper.execJs('$(\'head\').append(\'<link rel=\"stylesheet\" type=\"text\/css\" href=\"https:\/\/rawgit.com\/Jiiks\/BetterDiscordApp\/master\/css\/main.css\">\');');
|
||||
//TODO Load Main minified javascript
|
||||
|
||||
}, 5000);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
_helper.log("v" + _version + " initialized.");
|
||||
}
|
||||
|
||||
exports.BetterDiscordApp = BetterDiscordApp;
|
|
@ -1,31 +0,0 @@
|
|||
/* BetterDiscordApp Emote Module aka TwitchCord
|
||||
* See https://github.com/Jiiks/BetterDiscordApp/blob/master/js/emotemodule.js
|
||||
* Version: 1.0
|
||||
* Author: Jiiks | http://jiiks.net
|
||||
* Date: 25/08/2015 - 09:33
|
||||
* https://github.com/Jiiks/BetterDiscordApp
|
||||
*/
|
||||
|
||||
var config = require("../config.json");
|
||||
|
||||
var _helper;
|
||||
|
||||
function EmoteModule(helper) {
|
||||
_helper = helper;
|
||||
_helper.log("Emotes Initialized");
|
||||
|
||||
_helper.execJs('var twitchEmoteUrlStart = "' + config.EmoteModule.Twitch.EmoteUrlStart + '", twitchEmoteUrlEnd = "' + config.EmoteModule.Twitch.EmoteUrlEnd + '";');
|
||||
_helper.execJs('var ffzEmoteUrlStart = "' + config.EmoteModule.FrankerFaceZ.EmoteUrlStart + '", ffzEmoteUrlEnd = "' + config.EmoteModule.FrankerFaceZ.EmoteUrlEnd + '";');
|
||||
_helper.execJs('var bttvEmoteUrlStart = "' + config.EmoteModule.BetterTTV.EmoteUrlStart + '", bttvEmoteUrlEnd = "' + config.EmoteModule.BetterTTV.EmoteUrlEnd + '";');
|
||||
|
||||
_helper.download(config.Urls.Cdn + "master/" + config.EmoteModule.Twitch.EmoteData, function(twitchEmoteData) {
|
||||
_helper.execJs("var emotesTwitch = " + twitchEmoteData + ";");
|
||||
|
||||
_helper.download(config.Urls.Cdn + "master/" + config.EmoteModule.FrankerFaceZ.EmoteData, function(ffzEmoteData) {
|
||||
_helper.execJs("var emotesFfz = " + ffzEmoteData + ";");
|
||||
_helper.injectJavaScript(config.Cdn + config.js.EmoteModule);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.EmoteModule = EmoteModule;
|
Loading…
Reference in New Issue