/* BetterDiscordApp Core JavaScript * Version: 1.53 * Author: Jiiks | http://jiiks.net * Date: 27/08/2015 - 16:36 * Last Update: 01/05/2016 * https://github.com/Jiiks/BetterDiscordApp */ var settingsPanel, emoteModule, utils, quickEmoteMenu, opublicServers, voiceMode, pluginModule, themeModule, customCssEditor; var jsVersion = 1.70; var supportedVersion = "0.2.5"; var mainObserver; var twitchEmoteUrlStart = "https://static-cdn.jtvnw.net/emoticons/v1/"; var twitchEmoteUrlEnd = "/1.0"; var ffzEmoteUrlStart = "https://cdn.frankerfacez.com/emoticon/"; var ffzEmoteUrlEnd = "/1"; var bttvEmoteUrlStart = "https://cdn.betterttv.net/emote/"; var bttvEmoteUrlEnd = "/1x"; var mainCore; var settings = { "Save logs locally": { "id": "bda-gs-0", "info": "Saves chat logs locally", "implemented": false, "hidden": false, "cat": "core"}, "Public Servers": { "id": "bda-gs-1", "info": "Display public servers button", "implemented": true, "hidden": false, "cat": "core"}, "Minimal Mode": { "id": "bda-gs-2", "info": "Hide elements and reduce the size of elements.", "implemented": true, "hidden": false, "cat": "core"}, "Voice Mode": { "id": "bda-gs-4", "info": "Only show voice chat", "implemented": true, "hidden": false, "cat": "core"}, "Hide Channels": { "id": "bda-gs-3", "info": "Hide channels in minimal mode", "implemented": true, "hidden": false, "cat": "core"}, "Dark Mode": { "id": "bda-gs-5", "info": "Make certain elements dark by default(wip)", "implemented": true, "hidden": false, "cat": "core"}, "Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false, "hidden": false, "cat": "core"}, "Voice Disconnect": { "id": "bda-dc-0", "info": "Disconnect from voice server when closing Discord", "implemented": true, "hidden": false, "cat": "core"}, "Custom css live update": { "id": "bda-css-0", "info": "", "implemented": true, "hidden": true, "cat": "core"}, "Custom css auto udpate": { "id": "bda-css-1", "info": "", "implemented": true, "hidden": true, "cat": "core"}, "24 Hour Timestamps": { "id": "bda-gs-6", "info": "Replace 12hr timestamps with proper ones", "implemented": true, "hidden": false, "cat": "core"}, "Coloured Text": { "id": "bda-gs-7", "info": "Make text colour the same as role colour", "implemented": true, "hidden": false, "cat": "core"}, "Show Emotes": { "id": "bda-es-7", "info": "Show any emotes", "implemented": true, "hidden": false, "cat": "emote"}, "FrankerFaceZ Emotes": { "id": "bda-es-1", "info": "Show FrankerFaceZ Emotes", "implemented": true, "hidden": false, "cat": "emote"}, "BetterTTV Emotes": { "id": "bda-es-2", "info": "Show BetterTTV Emotes", "implemented": true, "hidden": false, "cat": "emote"}, "Emote Menu": { "id": "bda-es-0", "info": "Show Twitch/Favourite emotes in emote menu", "implemented": true, "hidden": false, "cat": "emote"}, "Emoji Menu": { "id": "bda-es-9", "info": "Show Discord emoji menu", "implemented": true, "hidden": false, "cat": "emote"}, "Emote Autocomplete": { "id": "bda-es-3", "info": "Autocomplete emote commands", "implemented": false, "hidden": false, "cat": "emote"}, "Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true, "hidden": false, "cat": "emote"}, "Show Names": { "id": "bda-es-6", "info": "Show emote names trueon hover", "implemented": true, "hidden": false, "cat": "emote"}, "Show emote modifiers": { "id": "bda-es-8", "info": "Enable emote mods", "implemented": true, "hidden": false, "cat": "emote"}, }; var links = { "Jiiks.net": { "text": "Jiiks.net", "href": "http://jiiks.net", "target": "_blank" }, "twitter": { "text": "Twitter", "href": "http://twitter.com/jiiksi", "target": "_blank" }, "github": { "text": "Github", "href": "http://github.com/jiiks", "target": "_blank" } }; var defaultCookie = { "version": jsVersion, "bda-gs-0": false, "bda-gs-1": true, "bda-gs-2": false, "bda-gs-3": false, "bda-gs-4": false, "bda-gs-5": true, "bda-gs-6": false, "bda-gs-7": false, "bda-es-0": true, "bda-es-1": true, "bda-es-2": true, "bda-es-3": false, "bda-es-4": false, "bda-es-5": true, "bda-es-6": true, "bda-es-7": true, "bda-es-8": true, "bda-jd": true, "bda-es-8": true, "bda-dc-0": false, "bda-css-0": false, "bda-css-1": false, "bda-es-9": true }; var bdchangelog = { "changes": { "028s": { "title": "v1.70 : 0.2.8 Support", "text": "Added support for Core version 0.2.8.", "img": "" }, "importexport": { "title": "v1.70 : Setting Import/Export", "text": "You can now import and export your settings!", "img": "" }, "infscroll": { "title": "v1.70 : Public Server List Infinite Scroll", "text": "Public server list now has the ability to load more than 20 servers.", "img": "" }, "tstamps": { "title": "v1.70 : 24 hour timestamps", "text": "Replace 12 hour timestamp with 24 hour timestamps!", "img": "" }, "ctext": { "title": "v1.70 : Coloured text", "text": "Make text colour the same as role colour!", "img": "" } }, "fixes": { "pserver": { "title": "v1.64 : Public Server Owner", "text": "Removed undefined server owner property", "imt": "" } } }; var settingsCookie = {}; function Core() {} Core.prototype.init = function () { var self = this; var lVersion = (typeof(version) === "undefined") ? bdVersion : version; if (lVersion < supportedVersion) { this.alert("Not Supported", "BetterDiscord v" + lVersion + "(your version)" + " is not supported by the latest js(" + jsVersion + ").

Please download the latest version from BetterDiscord.net"); return; } utils = new Utils(); var sock = new BdWSocket(); sock.start(); utils.getHash(); emoteModule = new EmoteModule(); quickEmoteMenu = new QuickEmoteMenu(); voiceMode = new VoiceMode(); emoteModule.init(); this.initSettings(); this.initObserver(); //Incase were too fast function gwDefer() { console.log(new Date().getTime() + " Defer"); if ($(".guilds-wrapper .guilds").children().length > 0) { console.log(new Date().getTime() + " Defer Loaded"); var guilds = $(".guilds>li:first-child"); var showChannelsButton = $("' + ' ' + '
' + '
'; if (bdchangelog.changes != null) { changeLog += '' + '

' + ' New Stuff' + '

' + ''; } if (bdchangelog.fixes != null) { changeLog += '' + '

' + ' Fixed' + '

' + ''; } if (bdchangelog.upcoming != null) { changeLog += '' + '

' + ' Coming Soon' + '

' + ''; } changeLog += '' + '
' + '
' + ' ' + ' ' + ' ' + ''; return changeLog; }; Core.prototype.alert = function (title, text) { var id = ''; for( var i=0; i < 5; i++ ) id += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(Math.random() * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".length)); var bdAlert = '\ \ '; $("body").append(bdAlert); utils.addBackdrop(id); }; /* BetterDiscordApp EmoteModule JavaScript * Version: 1.5 * Author: Jiiks | http://jiiks.net * Date: 26/08/2015 - 15:29 * Last Update: 14/10/2015 - 09:48 * https://github.com/Jiiks/BetterDiscordApp * Note: Due to conflicts autocapitalize only supports global emotes */ /* * =Changelog= * -v1.5 * --Twitchemotes.com api */ var emotesFfz = {}; var emotesBTTV = {}; var emotesTwitch = { "emotes": { "emote": { "image_id": 0 } } }; //for ide var subEmotesTwitch = {}; function EmoteModule() {} EmoteModule.prototype.init = function () {}; EmoteModule.prototype.getBlacklist = function () { $.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/" + _hash + "/data/emotefilter.json", function (data) { bemotes = data.blacklist; }); }; EmoteModule.prototype.obsCallback = function (mutation) { var self = this; if (!settingsCookie["bda-es-7"]) return; $(".emoji").each(function() { var t = $(this); if(t.attr("src").indexOf(".png") != -1) { t.replaceWith(t.attr("alt")); } }); /* $(".emoji").each(function () { var t = $(this); if (t.attr("src").indexOf(".png") != -1) { var next = t.next(); var newText = t.attr("alt"); if(next.size() > 0) { if(next.prop("tagName") == "SPAN") { newText += next.text(); next.remove(); } } if(t.parent().prop("tagName") != "SPAN") { t.replaceWith("" + newText + ""); } else { t.replaceWith(newText); } } });*/ for (var i = 0; i < mutation.addedNodes.length; ++i) { var next = mutation.addedNodes.item(i); if (next) { var nodes = self.getNodes(next); for (var node in nodes) { if (nodes.hasOwnProperty(node)) { self.injectEmote(nodes[node]); } } } } }; EmoteModule.prototype.getNodes = function (node) { var next; var nodes = []; var treeWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, null, false); while (next = treeWalker.nextNode()) { nodes.push(next); } return nodes; }; var bemotes = []; var spoilered = []; EmoteModule.prototype.injectEmote = function (node) { if (typeof emotesTwitch === 'undefined') return; if (!node.parentElement) return; var parent = node.parentElement; if (!$(parent).hasClass("markup")) { return; } var edited = false; /*if ($(parent.parentElement).hasClass("edited")) { parent = parent.parentElement.parentElement.firstChild; edited = true; }*/ function inject() { var p = $(parent); var parentInnerHTML = p.html(); var words = parentInnerHTML.split(/\s+/g); var injected = false; if (!words) return; var oldHeight = parent.parentElement.offsetHeight; words.forEach(function (word) { var w = word.replace("-->", "").replace("