BetterDiscordApp-rauenzi/js/utils.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-08-26 18:41:18 +02:00
/* BetterDiscordApp Utilities JavaScript
* Version: 1.0
* Author: Jiiks | http://jiiks.net
* Date: 26/08/2015 - 15:54
* https://github.com/Jiiks/BetterDiscordApp
*/
2015-11-01 12:37:04 +01:00
var _hash;
2015-08-26 18:41:18 +02:00
function Utils() {
}
Utils.prototype.getTextArea = function() {
return $(".channel-textarea-inner textarea");
};
2015-08-26 18:41:18 +02:00
Utils.prototype.jqDefer = function(fnc) {
if(window.jQuery) { fnc(); } else { setTimeout(function() { this.jqDefer(fnc) }, 100) }
2015-11-01 12:37:04 +01:00
};
Utils.prototype.getHash = function() {
2015-12-16 12:21:46 +01:00
$.getJSON("https://api.github.com/repos/Jiiks/BetterDiscordApp/commits/master", function(data) {
2015-11-01 12:37:04 +01:00
_hash = data.sha;
2015-12-16 12:21:46 +01:00
emoteModule.getBlacklist();
2015-11-01 12:37:04 +01:00
});
2015-12-16 12:21:46 +01:00
};
Utils.prototype.loadHtml = function(html, callback) {
var container = $("<div/>", {
class: "bd-container"
}).appendTo("body");
//TODO Inject these in next core update
html = '//cdn.rawgit.com/Jiiks/BetterDiscordApp/' + _hash + '/html/' + html + '.html';
container.load(html, callback());
};
Utils.prototype.injectJs = function(uri) {
$("<script/>", {
type: "text/javascript",
src: uri
}).appendTo($("body"));
};
2015-11-01 12:37:04 +01:00
2015-12-16 12:21:46 +01:00
Utils.prototype.injectCss = function(uri) {
$("<link/>", {
type: "text/css",
rel: "stylesheet",
href: uri
}).appendTo($("head"));
};