52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
/* BetterDiscordApp Utilities JavaScript
|
|
* Version: 1.0
|
|
* Author: Jiiks | http://jiiks.net
|
|
* Date: 26/08/2015 - 15:54
|
|
* https://github.com/Jiiks/BetterDiscordApp
|
|
*/
|
|
|
|
var _hash;
|
|
function Utils() {
|
|
|
|
}
|
|
|
|
Utils.prototype.getTextArea = function() {
|
|
return $(".channel-textarea-inner textarea");
|
|
};
|
|
|
|
Utils.prototype.jqDefer = function(fnc) {
|
|
if(window.jQuery) { fnc(); } else { setTimeout(function() { this.jqDefer(fnc) }, 100) }
|
|
};
|
|
|
|
Utils.prototype.getHash = function() {
|
|
$.getJSON("https://api.github.com/repos/Jiiks/BetterDiscordApp/commits/master", function(data) {
|
|
_hash = data.sha;
|
|
emoteModule.getBlacklist();
|
|
});
|
|
};
|
|
|
|
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"));
|
|
};
|
|
|
|
Utils.prototype.injectCss = function(uri) {
|
|
$("<link/>", {
|
|
type: "text/css",
|
|
rel: "stylesheet",
|
|
href: uri
|
|
}).appendTo($("head"));
|
|
}; |