Merge pull request #132 from pohky/master

compact mode fix
This commit is contained in:
Jiiks 2016-01-09 02:12:31 +02:00
commit 3dc9cd04ea
2 changed files with 707 additions and 532 deletions

View File

@ -5,8 +5,6 @@
* Last Update: 24/010/2015 - 17:27 * Last Update: 24/010/2015 - 17:27
* https://github.com/Jiiks/BetterDiscordApp * https://github.com/Jiiks/BetterDiscordApp
*/ */
var settingsPanel, emoteModule, utils, quickEmoteMenu, opublicServers, voiceMode, pluginModule, themeModule; var settingsPanel, emoteModule, utils, quickEmoteMenu, opublicServers, voiceMode, pluginModule, themeModule;
var jsVersion = 1.57; var jsVersion = 1.57;
var supportedVersion = "0.2.3"; var supportedVersion = "0.2.3";
@ -36,7 +34,7 @@ var settings = {
"Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true }, "Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true },
"Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false }, "Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false },
"Show Names": { "id": "bda-es-6", "info": "Show emote names on hover", "implemented": true } "Show Names": { "id": "bda-es-6", "info": "Show emote names on hover", "implemented": true }
} };
var links = { var links = {
"Jiiks.net": { "text": "Jiiks.net", "href": "http://jiiks.net", "target": "_blank" }, "Jiiks.net": { "text": "Jiiks.net", "href": "http://jiiks.net", "target": "_blank" },
@ -126,7 +124,26 @@ Core.prototype.init = function() {
console.log(new Date().getTime() + " Defer Loaded"); console.log(new Date().getTime() + " Defer Loaded");
var guilds = $(".guilds li:first-child"); var guilds = $(".guilds li:first-child");
guilds.after($("<li></li>", { id: "bd-pub-li", css: { "height": "20px", "display": settingsCookie["bda-gs-1"] == true ? "" : "none" } }).append($("<div/>", { class: "guild-inner", css: { "height": "20px", "border-radius": "4px" } }).append($("<a/>").append($("<div/>", { css: { "line-height": "20px", "font-size": "12px" }, text: "public", id: "bd-pub-button" }))))); guilds.after($("<li></li>", {
id: "bd-pub-li",
css: {
"height": "20px",
"display": settingsCookie["bda-gs-1"] == true ? "" : "none"
}
}).append($("<div/>", {
class: "guild-inner",
css: {
"height": "20px",
"border-radius": "4px"
}
}).append($("<a/>").append($("<div/>", {
css: {
"line-height": "20px",
"font-size": "12px"
},
text: "public",
id: "bd-pub-button"
})))));
var showChannelsButton = $("<button/>", { var showChannelsButton = $("<button/>", {
class: "btn", class: "btn",
@ -158,8 +175,12 @@ Core.prototype.init = function() {
quickEmoteMenu.init(false); quickEmoteMenu.init(false);
$("#tc-settings-button").on("click", function() { settingsPanel.show(); }); $("#tc-settings-button").on("click", function () {
$("#bd-pub-button").on("click", function() { opublicServers.show(); }); settingsPanel.show();
});
$("#bd-pub-button").on("click", function () {
opublicServers.show();
});
opublicServers.init(); opublicServers.init();
@ -207,7 +228,10 @@ Core.prototype.initSettings = function() {
}; };
Core.prototype.saveSettings = function () { Core.prototype.saveSettings = function () {
$.cookie("better-discord", JSON.stringify(settingsCookie), { expires: 365, path: '/' }); $.cookie("better-discord", JSON.stringify(settingsCookie), {
expires: 365,
path: '/'
});
}; };
Core.prototype.loadSettings = function () { Core.prototype.loadSettings = function () {
@ -224,16 +248,24 @@ Core.prototype.initObserver = function() {
voiceMode.obsCallback(); voiceMode.obsCallback();
if (typeof pluginModule !== "undefined") pluginModule.channelSwitch(); if (typeof pluginModule !== "undefined") pluginModule.channelSwitch();
$(".message-group").each(function () { $(".message-group").each(function () {
var a = $(this).find(".avatar-large").css("background-image").match(/\d+/).toString(); var a = $(this).find(".avatar-large");
if (a.length > 0) {
var b = a.css("background-image").match(/\d+/).toString();
if (botlist.indexOf(a) > -1) { if (botlist.indexOf(a) > -1) {
$(this).find(".user-name").addClass("boticon"); $(this).find(".user-name").addClass("boticon");
} }
}
}); });
} }
if (mutation.target.getAttribute('class').indexOf('scroller messages') != -1) { if (mutation.target.getAttribute('class').indexOf('scroller messages') != -1) {
var lastMessage = $(".message-group").last(); var lastMessage = $(".message-group").last();
if (lastMessage != undefined) { if (lastMessage != undefined) {
if(botlist.indexOf(lastMessage.find(".avatar-large").css("background-image").match(/\d+/).toString()) > -1) { lastMessage.find(".user-name").addClass("boticon"); } var a = lastMessage.find(".avatar-large");
if (a.length > 0) {
if (botlist.indexOf(a.css("background-image").match(/\d+/).toString()) > -1) {
lastMessage.find(".user-name").addClass("boticon");
}
}
} }
if (typeof pluginModule !== "undefined") pluginModule.newMessage(); if (typeof pluginModule !== "undefined") pluginModule.newMessage();
} }
@ -244,7 +276,10 @@ Core.prototype.initObserver = function() {
}); });
//noinspection JSCheckFunctionSignatures //noinspection JSCheckFunctionSignatures
mainObserver.observe(document, { childList: true, subtree: true }); mainObserver.observe(document, {
childList: true,
subtree: true
});
}; };
Core.prototype.constructChangelog = function () { Core.prototype.constructChangelog = function () {
@ -363,17 +398,23 @@ Core.prototype.alert = function(title, text) {
var emotesFfz = {}; var emotesFfz = {};
var emotesBTTV = {}; var emotesBTTV = {};
var emotesTwitch = { "emotes": { "emote": { "image_id": 0 } } }; //for ide var emotesTwitch = {
"emotes": {
"emote": {
"image_id": 0
}
}
}; //for ide
var subEmotesTwitch = {}; var subEmotesTwitch = {};
function EmoteModule() { function EmoteModule() {}
}
EmoteModule.prototype.init = function() { EmoteModule.prototype.init = function () {};
};
EmoteModule.prototype.getBlacklist = function () { EmoteModule.prototype.getBlacklist = function () {
$.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/"+_hash+"/emotefilter.json", function(data) { bemotes = data.blacklist; }); $.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/" + _hash + "/emotefilter.json", function (data) {
bemotes = data.blacklist;
});
}; };
EmoteModule.prototype.obsCallback = function (mutation) { EmoteModule.prototype.obsCallback = function (mutation) {
@ -438,7 +479,9 @@ EmoteModule.prototype.injectEmote = function(node) {
//if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) return; //if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) return;
function inject() { function inject() {
if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) { return; } if (!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) {
return;
}
var parentInnerHTML = parent.innerHTML; var parentInnerHTML = parent.innerHTML;
@ -582,7 +625,17 @@ EmoteModule.prototype.capitalize = function(value) {
* https://github.com/Jiiks/BetterDiscordApp * https://github.com/Jiiks/BetterDiscordApp
*/ */
var publicServers = { "servers": { "server": { "code": 0, "icon": null, "title": "title", "language": "EN", "description": "description" } } }; //for ide var publicServers = {
"servers": {
"server": {
"code": 0,
"icon": null,
"title": "title",
"language": "EN",
"description": "description"
}
}
}; //for ide
function PublicServers() { function PublicServers() {
@ -657,7 +710,9 @@ PublicServers.prototype.init = function() {
$("body").append(this.getPanel()); $("body").append(this.getPanel());
$("#bd-ps-close").on("click", function() { self.show(); }); $("#bd-ps-close").on("click", function () {
self.show();
});
var servers = publicServers.servers; var servers = publicServers.servers;
@ -715,7 +770,9 @@ PublicServers.prototype.addServer = function(name, code, title, language, descri
"outline": "1px solid #000", "outline": "1px solid #000",
"color": "#EDEDED" "color": "#EDEDED"
}, },
click: function() { self.joinServer(code); } click: function () {
self.joinServer(code);
}
}))); })));
tableBody.append(tr); tableBody.append(tr);
@ -763,7 +820,13 @@ QuickEmoteMenu.prototype.init = function(reload) {
var menuOpen; var menuOpen;
emoteBtn = $("<div/>", { id:"twitchcord-button-container", style:"display:none" }).append($("<button/>", { id: "twitchcord-button", onclick: "return false;" })); emoteBtn = $("<div/>", {
id: "twitchcord-button-container",
style: "display:none"
}).append($("<button/>", {
id: "twitchcord-button",
onclick: "return false;"
}));
$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn); $(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn);
@ -791,7 +854,10 @@ QuickEmoteMenu.prototype.init = function(reload) {
} }
}); });
$("#emote-menu").on("click", function() { $("#rmenu").hide(); return false; }); $("#emote-menu").on("click", function () {
$("#rmenu").hide();
return false;
});
if (settingsCookie["bda-es-0"]) { if (settingsCookie["bda-es-0"]) {
$(".channel-textarea").first().addClass("emotemenu-enabled"); $(".channel-textarea").first().addClass("emotemenu-enabled");
@ -833,22 +899,57 @@ var favoriteEmotes = {};
QuickEmoteMenu.prototype.initEmoteList = function () { QuickEmoteMenu.prototype.initEmoteList = function () {
emoteMenu = $("<div/>", { id: "emote-menu" }); emoteMenu = $("<div/>", {
id: "emote-menu"
});
var emoteMenuHeader = $("<div/>", { id: "emote-menu-header" }); var emoteMenuHeader = $("<div/>", {
var emoteMenuBody = $("<div/>", { id: "emote-menu-inner" }); id: "emote-menu-header"
var emoteMenuBodyFav = $("<div/>", { id: "emote-menu-inner-fav", css: { "display": "none" }}) });
var emoteMenuBody = $("<div/>", {
id: "emote-menu-inner"
});
var emoteMenuBodyFav = $("<div/>", {
id: "emote-menu-inner-fav",
css: {
"display": "none"
}
})
var globalTab = $("<div/>", {class: "emote-menu-tab emote-menu-tab-selected", id: "emgb", text: "Global", click: function() { $("#emfa").removeClass("emote-menu-tab-selected"); $("#emgb").addClass("emote-menu-tab-selected"); $("#emote-menu-inner-fav").hide(); $("#emote-menu-inner").show(); }}); var globalTab = $("<div/>", {
var favoriteTab = $("<div/>", {class: "emote-menu-tab", id: "emfa", text: "Favorite", click: function() { $("#emgb").removeClass("emote-menu-tab-selected"); $("#emfa").addClass("emote-menu-tab-selected"); $("#emote-menu-inner").hide(); $("#emote-menu-inner-fav").show(); }}); class: "emote-menu-tab emote-menu-tab-selected",
id: "emgb",
text: "Global",
click: function () {
$("#emfa").removeClass("emote-menu-tab-selected");
$("#emgb").addClass("emote-menu-tab-selected");
$("#emote-menu-inner-fav").hide();
$("#emote-menu-inner").show();
}
});
var favoriteTab = $("<div/>", {
class: "emote-menu-tab",
id: "emfa",
text: "Favorite",
click: function () {
$("#emgb").removeClass("emote-menu-tab-selected");
$("#emfa").addClass("emote-menu-tab-selected");
$("#emote-menu-inner").hide();
$("#emote-menu-inner-fav").show();
}
});
emoteMenuHeader.append(globalTab); emoteMenuHeader.append(globalTab);
emoteMenuHeader.append(favoriteTab); emoteMenuHeader.append(favoriteTab);
emoteMenu.append(emoteMenuHeader); emoteMenu.append(emoteMenuHeader);
var swrapper = $("<div/>", { class: "scroller-wrap" }); var swrapper = $("<div/>", {
var scroller = $("<div/>", { class: "scroller"}); class: "scroller-wrap"
});
var scroller = $("<div/>", {
class: "scroller"
});
swrapper.append(scroller); swrapper.append(scroller);
@ -860,7 +961,15 @@ QuickEmoteMenu.prototype.initEmoteList = function() {
for (var emote in emotesTwitch.emotes) { for (var emote in emotesTwitch.emotes) {
if (emotesTwitch.emotes.hasOwnProperty(emote)) { if (emotesTwitch.emotes.hasOwnProperty(emote)) {
var id = emotesTwitch.emotes[emote].image_id; var id = emotesTwitch.emotes[emote].image_id;
emoteMenuBody.append($("<div/>" , { class: "emote-container" }).append($("<img/>", { class: "emote-icon", id: emote, alt: "", src: "https://static-cdn.jtvnw.net/emoticons/v1/"+id+"/1.0", title: emote }))); emoteMenuBody.append($("<div/>", {
class: "emote-container"
}).append($("<img/>", {
class: "emote-icon",
id: emote,
alt: "",
src: "https://static-cdn.jtvnw.net/emoticons/v1/" + id + "/1.0",
title: emote
})));
} }
} }
}; };
@ -889,8 +998,15 @@ QuickEmoteMenu.prototype.updateFavorites = function() {
for (var emote in favoriteEmotes) { for (var emote in favoriteEmotes) {
var url = favoriteEmotes[emote]; var url = favoriteEmotes[emote];
var econtainer = $("<div/>", { class: "emote-container" }); var econtainer = $("<div/>", {
var icon = $("<img/>", { class: "emote-icon", alt: "", src: url, title: emote }).appendTo(econtainer); class: "emote-container"
});
var icon = $("<img/>", {
class: "emote-icon",
alt: "",
src: url,
title: emote
}).appendTo(econtainer);
emoteMenuBody.append(econtainer); emoteMenuBody.append(econtainer);
icon.off("click").on("click", function (e) { icon.off("click").on("click", function (e) {
@ -906,7 +1022,10 @@ QuickEmoteMenu.prototype.updateFavorites = function() {
self.updateFavorites(); self.updateFavorites();
}); });
menu.hide(); menu.hide();
menu.css({top: e.pageY, left: e.pageX}); menu.css({
top: e.pageY,
left: e.pageX
});
menu.show(); menu.show();
return false; return false;
}); });
@ -967,8 +1086,17 @@ SettingsPanel.prototype.init = function() {
if (settingsCookie["bda-es-6"]) { if (settingsCookie["bda-es-6"]) {
//Pretty emote titles //Pretty emote titles
emoteNamePopup = $("<div class='tipsy tipsy-se' style='display: block; top: 82px; left: 1630.5px; visibility: visible; opacity: 0.8;'><div class='tipsy-inner'></div></div>"); emoteNamePopup = $("<div class='tipsy tipsy-se' style='display: block; top: 82px; left: 1630.5px; visibility: visible; opacity: 0.8;'><div class='tipsy-inner'></div></div>");
$(document).on("mouseover", ".emote", function() { var x = $(this).offset(); var title = $(this).attr("alt"); $(emoteNamePopup).find(".tipsy-inner").text(title); $(emoteNamePopup).css('left', x.left - 25); $(emoteNamePopup).css('top', x.top - 32); $("div[data-reactid='.0.1.1']").append($(emoteNamePopup));}); $(document).on("mouseover", ".emote", function () {
$(document).on("mouseleave", ".emote", function(){$(".tipsy").remove()}); var x = $(this).offset();
var title = $(this).attr("alt");
$(emoteNamePopup).find(".tipsy-inner").text(title);
$(emoteNamePopup).css('left', x.left - 25);
$(emoteNamePopup).css('top', x.top - 32);
$("div[data-reactid='.0.1.1']").append($(emoteNamePopup));
});
$(document).on("mouseleave", ".emote", function () {
$(".tipsy").remove()
});
} else { } else {
$(document).off('mouseover', '.emote'); $(document).off('mouseover', '.emote');
} }
@ -1005,7 +1133,10 @@ SettingsPanel.prototype.changeTab = function(tab) {
case "bd-customcss-tab": case "bd-customcss-tab":
if (!customCssInitialized) { if (!customCssInitialized) {
var editor = CodeMirror.fromTextArea(document.getElementById("bd-custom-css-ta"), { var editor = CodeMirror.fromTextArea(document.getElementById("bd-custom-css-ta"), {
lineNumbers: true, mode: 'css', indentUnit: 4, theme: 'neat' lineNumbers: true,
mode: 'css',
indentUnit: 4,
theme: 'neat'
}); });
@ -1064,8 +1195,17 @@ SettingsPanel.prototype.updateSetting = function(checkbox) {
if (settingsCookie["bda-es-6"]) { if (settingsCookie["bda-es-6"]) {
//Pretty emote titles //Pretty emote titles
emoteNamePopup = $("<div class='tipsy tipsy-se' style='display: block; top: 82px; left: 1630.5px; visibility: visible; opacity: 0.8;'><div class='tipsy-inner'></div></div>"); emoteNamePopup = $("<div class='tipsy tipsy-se' style='display: block; top: 82px; left: 1630.5px; visibility: visible; opacity: 0.8;'><div class='tipsy-inner'></div></div>");
$(document).on("mouseover", ".emote", function() { var x = $(this).offset(); var title = $(this).attr("alt"); $(emoteNamePopup).find(".tipsy-inner").text(title); $(emoteNamePopup).css('left', x.left - 25); $(emoteNamePopup).css('top', x.top - 32); $("div[data-reactid='.0.1.1']").append($(emoteNamePopup));}); $(document).on("mouseover", ".emote", function () {
$(document).on("mouseleave", ".emote", function(){$(".tipsy").remove()}); var x = $(this).offset();
var title = $(this).attr("alt");
$(emoteNamePopup).find(".tipsy-inner").text(title);
$(emoteNamePopup).css('left', x.left - 25);
$(emoteNamePopup).css('top', x.top - 32);
$("div[data-reactid='.0.1.1']").append($(emoteNamePopup));
});
$(document).on("mouseleave", ".emote", function () {
$(".tipsy").remove()
});
} else { } else {
$(document).off('mouseover', '.emote'); $(document).off('mouseover', '.emote');
} }
@ -1261,6 +1401,7 @@ SettingsPanel.prototype.construct = function() {
*/ */
var _hash; var _hash;
function Utils() { function Utils() {
} }
@ -1270,7 +1411,13 @@ Utils.prototype.getTextArea = function() {
}; };
Utils.prototype.jqDefer = function (fnc) { Utils.prototype.jqDefer = function (fnc) {
if(window.jQuery) { fnc(); } else { setTimeout(function() { this.jqDefer(fnc) }, 100) } if (window.jQuery) {
fnc();
} else {
setTimeout(function () {
this.jqDefer(fnc)
}, 100)
}
}; };
Utils.prototype.getHash = function () { Utils.prototype.getHash = function () {
@ -1434,7 +1581,10 @@ PluginModule.prototype.loadPluginData = function() {
}; };
PluginModule.prototype.savePluginData = function () { PluginModule.prototype.savePluginData = function () {
$.cookie("bd-plugins", JSON.stringify(pluginCookie), { expires: 365, path: '/' }); $.cookie("bd-plugins", JSON.stringify(pluginCookie), {
expires: 365,
path: '/'
});
}; };
PluginModule.prototype.newMessage = function () { PluginModule.prototype.newMessage = function () {
@ -1524,7 +1674,10 @@ ThemeModule.prototype.loadThemeData = function() {
}; };
ThemeModule.prototype.saveThemeData = function () { ThemeModule.prototype.saveThemeData = function () {
$.cookie("bd-themes", JSON.stringify(themeCookie), { expires: 365, path: '/' }); $.cookie("bd-themes", JSON.stringify(themeCookie), {
expires: 365,
path: '/'
});
}; };
@ -1542,7 +1695,9 @@ BdWSocket.prototype.start = function() {
$.ajax({ $.ajax({
method: "GET", method: "GET",
url: "https://discordapp.com/api/gateway", url: "https://discordapp.com/api/gateway",
headers: {authorization: localStorage.token.match(/\"(.+)\"/)[1]}, headers: {
authorization: localStorage.token.match(/\"(.+)\"/)[1]
},
success: function (data) { success: function (data) {
self.open(data.url); self.open(data.url);
} }
@ -1557,7 +1712,9 @@ BdWSocket.prototype.open = function(host) {
bdSocket.onmessage = this.onMessage; bdSocket.onmessage = this.onMessage;
bdSocket.onerror = this.onError; bdSocket.onerror = this.onError;
bdSocket.onclose = this.onClose; bdSocket.onclose = this.onClose;
}catch(err) { utils.log(err); } } catch (err) {
utils.log(err);
}
}; };
@ -1588,7 +1745,10 @@ BdWSocket.prototype.onMessage = function(e) {
switch (type) { switch (type) {
case "READY": case "READY":
bdSocket.interval = setInterval(() => bdws.send({ op: 1, d: Date.now() }), data.heartbeat_interval); bdSocket.interval = setInterval(() => bdws.send({
op: 1,
d: Date.now()
}), data.heartbeat_interval);
utils.log("Socket Ready"); utils.log("Socket Ready");
break; break;
case "PRESENCE_UPDATE": case "PRESENCE_UPDATE":
@ -1716,12 +1876,28 @@ BdApi.getUserNameById = function(id) {
//Set current game //Set current game
//game = game //game = game
BdApi.setPlaying = function (game) { BdApi.setPlaying = function (game) {
bdws.send({"op":3,"d":{"idle_since":null,"game":{"name": game}}}); bdws.send({
"op": 3,
"d": {
"idle_since": null,
"game": {
"name": game
}
}
});
}; };
//Set current status //Set current status
//idle_since = date //idle_since = date
//status = status //status = status
BdApi.setStatus = function (idle_since, status) { BdApi.setStatus = function (idle_since, status) {
bdws.send({"op":3,"d":{"idle_since":idle_since,"game":{"name": status}}}); bdws.send({
"op": 3,
"d": {
"idle_since": idle_since,
"game": {
"name": status
}
}
});
}; };

7
js/main.min.js vendored
View File

@ -1,11 +1,10 @@
var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule;var jsVersion=1.57;var supportedVersion="0.2.3";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},"Public Servers":{"id":"bda-gs-1","info":"Display public servers button","implemented":true},"Minimal Mode":{"id":"bda-gs-2","info":"Hide elements and reduce the size of elements.","implemented":true},"Voice Mode":{"id":"bda-gs-4","info":"Only show voice chat","implemented":true},"Hide Channels":{"id":"bda-gs-3","info":"Hide channels in minimal mode","implemented":true},"Quick Emote Menu":{"id":"bda-es-0","info":"Show quick emote menu for adding emotes","implemented":true},"Show Emotes":{"id":"bda-es-7","info":"Show any emotes","implemented":true},"FrankerFaceZ Emotes":{"id":"bda-es-1","info":"Show FrankerFaceZ Emotes","implemented":true},"BetterTTV Emotes":{"id":"bda-es-2","info":"Show BetterTTV Emotes","implemented":true},"Emote Autocomplete":{"id":"bda-es-3","info":"Autocomplete emote commands","implemented":false},"Emote Auto Capitalization":{"id":"bda-es-4","info":"Autocapitalize emote commands","implemented":true},"Override Default Emotes":{"id":"bda-es-5","info":"Override default emotes","implemented":false},"Show Names":{"id":"bda-es-6","info":"Show emote names on hover","implemented":true}} var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule;var jsVersion=1.57;var supportedVersion="0.2.3";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},"Public Servers":{"id":"bda-gs-1","info":"Display public servers button","implemented":true},"Minimal Mode":{"id":"bda-gs-2","info":"Hide elements and reduce the size of elements.","implemented":true},"Voice Mode":{"id":"bda-gs-4","info":"Only show voice chat","implemented":true},"Hide Channels":{"id":"bda-gs-3","info":"Hide channels in minimal mode","implemented":true},"Quick Emote Menu":{"id":"bda-es-0","info":"Show quick emote menu for adding emotes","implemented":true},"Show Emotes":{"id":"bda-es-7","info":"Show any emotes","implemented":true},"FrankerFaceZ Emotes":{"id":"bda-es-1","info":"Show FrankerFaceZ Emotes","implemented":true},"BetterTTV Emotes":{"id":"bda-es-2","info":"Show BetterTTV Emotes","implemented":true},"Emote Autocomplete":{"id":"bda-es-3","info":"Autocomplete emote commands","implemented":false},"Emote Auto Capitalization":{"id":"bda-es-4","info":"Autocapitalize emote commands","implemented":true},"Override Default Emotes":{"id":"bda-es-5","info":"Override default emotes","implemented":false},"Show Names":{"id":"bda-es-6","info":"Show emote names on hover","implemented":true}};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-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-jd":true};var bdchangelog={"changes":{"api":{"title":"Api Functions!","text":"New api events!","img":""},"dec":{"title":"Decorations&Snow!","text":"Decorations and snow have been removed.","img":""}},"fixes":{"emotes":{"title":"Sub emotes!","text":"Discord sub emotes are now replaced by BetterDiscord sub emotes and can be favorited!","img":""}},"upcoming":{"ignore":{"title":"Ignore User!","text":"Ignore users you don't like!","img":""}}};var settingsCookie={};function Core(){}
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-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-jd":true};var bdchangelog={"changes":{"api":{"title":"Api Functions!","text":"New api events!","img":""},"dec":{"title":"Decorations&Snow!","text":"Decorations and snow have been removed.","img":""}},"fixes":{"emotes":{"title":"Sub emotes!","text":"Discord sub emotes are now replaced by BetterDiscord sub emotes and can be favorited!","img":""}},"upcoming":{"ignore":{"title":"Ignore User!","text":"Ignore users you don't like!","img":""}}};var settingsCookie={};function Core(){}
Core.prototype.init=function(){var self=this;if(version<supportedVersion){this.alert("Not Supported","BetterDiscord v"+version+"(your version)"+" is not supported by the latest js("+jsVersion+").<br><br> Please download the latest version from <a href='https://betterdiscord.net' target='_blank'>BetterDiscord.net</a>");return;} Core.prototype.init=function(){var self=this;if(version<supportedVersion){this.alert("Not Supported","BetterDiscord v"+version+"(your version)"+" is not supported by the latest js("+jsVersion+").<br><br> Please download the latest version from <a href='https://betterdiscord.net' target='_blank'>BetterDiscord.net</a>");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();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");guilds.after($("<li></li>",{id:"bd-pub-li",css:{"height":"20px","display":settingsCookie["bda-gs-1"]==true?"":"none"}}).append($("<div/>",{class:"guild-inner",css:{"height":"20px","border-radius":"4px"}}).append($("<a/>").append($("<div/>",{css:{"line-height":"20px","font-size":"12px"},text:"public",id:"bd-pub-button"})))));var showChannelsButton=$("<button/>",{class:"btn",id:"bd-show-channels",text:"R",css:{"cursor":"pointer"},click:function(){settingsCookie["bda-gs-3"]=false;$("body").removeClass("bd-minimal-chan");self.saveSettings();}});$(".guilds-wrapper").prepend(showChannelsButton);opublicServers=new PublicServers();pluginModule=new PluginModule();pluginModule.loadPlugins();if(typeof(themesupport2)!=="undefined"){themeModule=new ThemeModule();themeModule.loadThemes();} 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();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");guilds.after($("<li></li>",{id:"bd-pub-li",css:{"height":"20px","display":settingsCookie["bda-gs-1"]==true?"":"none"}}).append($("<div/>",{class:"guild-inner",css:{"height":"20px","border-radius":"4px"}}).append($("<a/>").append($("<div/>",{css:{"line-height":"20px","font-size":"12px"},text:"public",id:"bd-pub-button"})))));var showChannelsButton=$("<button/>",{class:"btn",id:"bd-show-channels",text:"R",css:{"cursor":"pointer"},click:function(){settingsCookie["bda-gs-3"]=false;$("body").removeClass("bd-minimal-chan");self.saveSettings();}});$(".guilds-wrapper").prepend(showChannelsButton);opublicServers=new PublicServers();pluginModule=new PluginModule();pluginModule.loadPlugins();if(typeof(themesupport2)!=="undefined"){themeModule=new ThemeModule();themeModule.loadThemes();}
settingsPanel=new SettingsPanel();settingsPanel.init();quickEmoteMenu.init(false);$("#tc-settings-button").on("click",function(){settingsPanel.show();});$("#bd-pub-button").on("click",function(){opublicServers.show();});opublicServers.init();emoteModule.autoCapitalize();if(settingsCookie["version"]<jsVersion){var cl=self.constructChangelog();$("body").append(cl);settingsCookie["version"]=jsVersion;self.saveSettings();} settingsPanel=new SettingsPanel();settingsPanel.init();quickEmoteMenu.init(false);$("#tc-settings-button").on("click",function(){settingsPanel.show();});$("#bd-pub-button").on("click",function(){opublicServers.show();});opublicServers.init();emoteModule.autoCapitalize();if(settingsCookie["version"]<jsVersion){var cl=self.constructChangelog();$("body").append(cl);settingsCookie["version"]=jsVersion;self.saveSettings();}
$("head").append("<style>.CodeMirror{ min-width:100%; }</style>");$("head").append('<style id="bdemotemenustyle"></style>');}else{setTimeout(gwDefer,100);}} $("head").append("<style>.CodeMirror{ min-width:100%; }</style>");$("head").append('<style id="bdemotemenustyle"></style>');}else{setTimeout(gwDefer,100);}}
$(document).ready(function(){setTimeout(gwDefer,1000);});};Core.prototype.initSettings=function(){if($.cookie("better-discord")==undefined){settingsCookie=defaultCookie;this.saveSettings();}else{this.loadSettings();for(var setting in defaultCookie){if(settingsCookie[setting]==undefined){settingsCookie[setting]=defaultCookie[setting];this.saveSettings();}}}};Core.prototype.saveSettings=function(){$.cookie("better-discord",JSON.stringify(settingsCookie),{expires:365,path:'/'});};Core.prototype.loadSettings=function(){settingsCookie=JSON.parse($.cookie("better-discord"));};var botlist=["119598467310944259"];Core.prototype.initObserver=function(){mainObserver=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.target.getAttribute('class')!=null){if(mutation.target.getAttribute('class').indexOf("titlebar")!=-1){quickEmoteMenu.obsCallback();voiceMode.obsCallback();if(typeof pluginModule!=="undefined")pluginModule.channelSwitch();$(".message-group").each(function(){var a=$(this).find(".avatar-large").css("background-image").match(/\d+/).toString();if(botlist.indexOf(a)>-1){$(this).find(".user-name").addClass("boticon");}});} $(document).ready(function(){setTimeout(gwDefer,1000);});};Core.prototype.initSettings=function(){if($.cookie("better-discord")==undefined){settingsCookie=defaultCookie;this.saveSettings();}else{this.loadSettings();for(var setting in defaultCookie){if(settingsCookie[setting]==undefined){settingsCookie[setting]=defaultCookie[setting];this.saveSettings();}}}};Core.prototype.saveSettings=function(){$.cookie("better-discord",JSON.stringify(settingsCookie),{expires:365,path:'/'});};Core.prototype.loadSettings=function(){settingsCookie=JSON.parse($.cookie("better-discord"));};var botlist=["119598467310944259"];Core.prototype.initObserver=function(){mainObserver=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.target.getAttribute('class')!=null){if(mutation.target.getAttribute('class').indexOf("titlebar")!=-1){quickEmoteMenu.obsCallback();voiceMode.obsCallback();if(typeof pluginModule!=="undefined")pluginModule.channelSwitch();$(".message-group").each(function(){var a=$(this).find(".avatar-large");if(a.length>0){var b=a.css("background-image").match(/\d+/).toString();if(botlist.indexOf(a)>-1){$(this).find(".user-name").addClass("boticon");}}});}
if(mutation.target.getAttribute('class').indexOf('scroller messages')!=-1){var lastMessage=$(".message-group").last();if(lastMessage!=undefined){if(botlist.indexOf(lastMessage.find(".avatar-large").css("background-image").match(/\d+/).toString())>-1){lastMessage.find(".user-name").addClass("boticon");}} if(mutation.target.getAttribute('class').indexOf('scroller messages')!=-1){var lastMessage=$(".message-group").last();if(lastMessage!=undefined){var a=lastMessage.find(".avatar-large");if(a.length>0){if(botlist.indexOf(a.css("background-image").match(/\d+/).toString())>-1){lastMessage.find(".user-name").addClass("boticon");}}}
if(typeof pluginModule!=="undefined")pluginModule.newMessage();}} if(typeof pluginModule!=="undefined")pluginModule.newMessage();}}
emoteModule.obsCallback(mutation);});});mainObserver.observe(document,{childList:true,subtree:true});};Core.prototype.constructChangelog=function(){var changeLog=''+'<div id="bd-wn-modal" class="modal" style="opacity:1;">'+' <div class="modal-inner">'+' <div id="bdcl" class="change-log"> '+' <div class="header">'+' <strong>What\'s new in BetterDiscord JS v1.53&'+jsVersion+'</strong>'+' <button class="close" onclick=\'$("#bd-wn-modal").remove();\'></button>'+' </div><!--header-->'+' <div class="scroller-wrap">'+' <div class="scroller">';if(bdchangelog.changes!=null){changeLog+=''+'<h1 class="changelog-added">'+' <span>New Stuff</span>'+'</h1>'+'<ul>';for(var change in bdchangelog.changes){change=bdchangelog.changes[change];changeLog+=''+'<li>'+' <strong>'+change.title+'</strong>'+' <div>'+change.text+'</div>'+'</li>';} emoteModule.obsCallback(mutation);});});mainObserver.observe(document,{childList:true,subtree:true});};Core.prototype.constructChangelog=function(){var changeLog=''+'<div id="bd-wn-modal" class="modal" style="opacity:1;">'+' <div class="modal-inner">'+' <div id="bdcl" class="change-log"> '+' <div class="header">'+' <strong>What\'s new in BetterDiscord JS v1.53&'+jsVersion+'</strong>'+' <button class="close" onclick=\'$("#bd-wn-modal").remove();\'></button>'+' </div><!--header-->'+' <div class="scroller-wrap">'+' <div class="scroller">';if(bdchangelog.changes!=null){changeLog+=''+'<h1 class="changelog-added">'+' <span>New Stuff</span>'+'</h1>'+'<ul>';for(var change in bdchangelog.changes){change=bdchangelog.changes[change];changeLog+=''+'<li>'+' <strong>'+change.title+'</strong>'+' <div>'+change.text+'</div>'+'</li>';}
changeLog+='</ul>';} changeLog+='</ul>';}