JS v1.6 and updated readme

This commit is contained in:
Jiiks 2016-04-07 15:08:16 +03:00
parent 14eedbb26c
commit 480254aedc
5 changed files with 338 additions and 160 deletions

View File

@ -48,7 +48,8 @@ Minimal mode makes elements smaller and hides certain elements.
Only display voice channels Only display voice channels
**Public Servers:** **Public Servers:**
A menu for displaying public servers. [Serverlist](https://github.com/Jiiks/BetterDiscordApp/blob/master/data/serverlist.json) A modal window for public servers [DiscordServers.com](https://www.discordservers.com/)
![ss](http://puu.sh/o9oNl.png)
**Custom CSS** **Custom CSS**
BetterDiscord supports custom CSS for styling Discord to your liking. BetterDiscord supports custom CSS for styling Discord to your liking.
@ -66,7 +67,8 @@ Add spoilers to your chat, simply add [!s] to your message.
Save chatlogs locally.(soon) Save chatlogs locally.(soon)
## Adding your server to public servers ## Adding your server to public servers
Edit the [Serverlist](https://github.com/Jiiks/BetterDiscordApp/blob/master/data/serverlist.json) and submit a pull request. As of JS1.60 the public server list is supplied by [DiscordServers.com](https://www.discordservers.com/)
Add your server there and it will appear in the list!
## BetterDiscord Uses the following API's ## BetterDiscord Uses the following API's
* https://twitchemotes.com/apidocs for Twitch emotes * https://twitchemotes.com/apidocs for Twitch emotes
@ -81,7 +83,7 @@ Edit the [Serverlist](https://github.com/Jiiks/BetterDiscordApp/blob/master/data
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015 Jiiks | [Jiiks.net] (https://jiiks.net) Copyright (c) 2015-2016 Jiiks | [Jiiks.net] (https://jiiks.net)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

File diff suppressed because one or more lines are too long

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
* 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.59; var jsVersion = 1.6;
var supportedVersion = "0.2.5"; var supportedVersion = "0.2.5";
var mainObserver; var mainObserver;
@ -64,30 +64,35 @@ var defaultCookie = {
var bdchangelog = { var bdchangelog = {
"changes": { "changes": {
"pslist": {
"title": "v1.60 : New public server list!",
"text": 'New and shiny public server list powered by <a href="https://www.discordservers.com/" target="_blank">DiscordServers.com</a>!',
"img": ""
},
"api": { "api": {
"title": "New plugin api callback", "title": "v1.59 : New plugin api callback",
"text": "Use the `observer(e)` callback instead of creating your own MutationObserver", "text": "Use the `observer(e)` callback instead of creating your own MutationObserver",
"img": "" "img": ""
}, },
"emotemods": { "emotemods": {
"title": "New emote mods!", "title": "v1.59 : New emote mods!",
"text": "The following emote mods have been added: :shake2, :shake3, :flap", "text": "The following emote mods have been added: :shake2, :shake3, :flap",
"img": "" "img": ""
}, },
"minmode": { "minmode": {
"title": "Minimal mode", "title": "v1.59: Minimal mode",
"text": "Minimal mode embed fixed size has been removed", "text": "Minimal mode embed fixed size has been removed",
"img": "" "img": ""
} }
}, },
"fixes": { "fixes": {
"emotes": { "emotes": {
"title": "Native sub emote mods", "title": "v1.59 : Native sub emote mods",
"text": "Emote mods now work with native sub emotes!", "text": "Emote mods now work with native sub emotes!",
"img": "" "img": ""
}, },
"emotes2": { "emotes2": {
"title": "Emote mods and custom emotes", "title": "v1.59 : Emote mods and custom emotes",
"text": "Emote mods will no longer interfere with custom emotes using :", "text": "Emote mods will no longer interfere with custom emotes using :",
"img": "" "img": ""
} }
@ -590,9 +595,9 @@ EmoteModule.prototype.injectEmote = function (node) {
parent.innerHTML = parentInnerHTML.replace(new RegExp("\uFDD9", "g"), ""); parent.innerHTML = parentInnerHTML.replace(new RegExp("\uFDD9", "g"), "");
var newHeight = parent.parentElement.offsetHeight; var newHeight = parent.parentElement.offsetHeight;
//Scrollfix
var scrollPane = $(".scroller.messages").first(); var scrollPane = $(".scroller.messages").first();
scrollPane.scrollTop(scrollPane.scrollTop() + (newHeight - oldHeight)); scrollPane.scrollTop(scrollPane.scrollTop() + (newHeight - oldHeight));
} }
if (edited) { if (edited) {
@ -641,18 +646,6 @@ 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
function PublicServers() { function PublicServers() {
} }
@ -662,145 +655,172 @@ PublicServers.prototype.getPanel = function () {
}; };
PublicServers.prototype.init = function () { PublicServers.prototype.init = function () {
var panelBase="";
var self = this; panelBase += "<div id=\"pubs-container\">";
panelBase += " <div id=\"pubs-spinner\">";
this.container = $("<div/>", { panelBase += " <span class=\"spinner\" type=\"wandering-cubes\"><span class=\"spinner-inner spinner-wandering-cubes\"><span class=\"spinner-item\"><\/span><span class=\"spinner-item\"><\/span><\/span><\/span>";
id: "bd-ps-container", panelBase += " <\/div>";
style: "display:none" panelBase += " <div id=\"pubs-header\">";
}); panelBase += " <h2 id=\"pubs-header-title\">Public Servers<\/h2>";
panelBase += " <button id=\"sbtn\">Search<\/button>";
var header = $("<div/>", { panelBase += " <input id=\"sterm\" type=\"text\" placeholder=\"Search term...\"\/>";
id: "bd-ps-header" panelBase += " <\/div>";
}); panelBase += " <div class=\"scroller-wrap\">";
panelBase += " <div class=\"scroller\">";
$("<h2/>", { panelBase += " <div id=\"slist\" class=\"servers-listing\">";
text: "Public Servers" panelBase += " ";
}).appendTo(header); panelBase += " <\/div>";
panelBase += " <\/div>";
$("<span/>", { panelBase += " <\/div>";
id: "bd-ps-close", panelBase += " <div id=\"pubs-footer\">";
style: "cursor:pointer;", panelBase += " <div>Server list provided by <a href=\"https:\/\/www.discordservers.com\/\" target=\"_blank\">DiscordServers.com<\/a><\/div>";
text: "X" panelBase += " <\/div>";
}).appendTo(header); panelBase += "<\/div>";
this.container = panelBase;
header.appendTo(this.getPanel());
var psbody = $("<div/>", {
id: "bd-ps-body"
});
psbody.appendTo(this.getPanel());
var table = $("<table/>", {
border: "0"
});
var thead = $("<thead/>");
thead.appendTo(table);
var headers = $("<tr/>", {
}).append($("<th/>", {
text: "Name"
})).append($("<th/>", {
text: "Code"
})).append($("<th/>", {
text: "Language"
})).append($("<th/>", {
text: "Description"
})).append($("<th/>", {
text: "Join"
}));
headers.appendTo(thead);
var tbody = $("<tbody/>", {
id: "bd-ps-tbody"
});
tbody.appendTo(table);
table.appendTo(psbody);
$("body").append(this.getPanel());
$("#bd-ps-close").on("click", function () {
self.show();
});
var servers = publicServers.servers;
for (var server in servers) {
if (servers.hasOwnProperty(server)) {
var s = servers[server];
var code = s.code;
var title = s.title;
var language = s.language;
var description = s.description;
this.addServer(server, code, title, language, description);
}
}
}; };
PublicServers.prototype.addServer = function (name, code, title, language, description) {
var self = this;
var tableBody = $("#bd-ps-tbody");
var desc = $("<td/>").append($("<div/>", {
class: "bd-ps-description",
text: description
}));
var tr = $("<tr/>");
tr.append($("<td/>", {
text: title
}));
tr.append($("<td/>", {
css: {
"-webkit-user-select": "initial",
"user-select": "initial"
},
text: code
}));
tr.append($("<td/>", {
text: language
}));
tr.append(desc);
tr.append($("<td/>").append($("<button/>", {
text: "Join",
css: {
"height": "30px",
"display": "block",
"margin-top": "10px",
"background-color": "#36393E",
"border": "1px solid #404040",
"outline": "1px solid #000",
"color": "#EDEDED"
},
click: function () {
self.joinServer(code);
}
})));
tableBody.append(tr);
};
PublicServers.prototype.show = function () { PublicServers.prototype.show = function () {
this.getPanel().toggle(); var self = this;
var li = $("#bd-pub-li"); $("body").append(this.getPanel());
li.removeClass();
if (this.getPanel().is(":visible")) { var dataset = {
li.addClass("active"); "sort": [{
"online": "desc"
}],
"from": 0,
"size": 20,
"query": {
"filtered": {
"query": {
"match_all": {}
} }
}
}
};
$("#sbtn").on("click", function() {
self.search();
});
$("#sterm").on("keyup", function(e) {
if (e.keyCode == 13) {
self.search();
}
});
this.loadServers(dataset, false);
var self = this;
$(document).on("mouseup.bdps",function(e) {
if(!$("#bd-pub-button").is(e.target) && !$("#pubs-container").is(e.target) && $("#pubs-container").has(e.target).length === 0) {
self.hide();
}
});
};
PublicServers.prototype.hide = function() {
$("#pubs-container").remove();
$(document).off("mouseup.bdps");
};
PublicServers.prototype.loadServers = function(dataset, search) {
var self = this;
$("#sbtn").prop("disabled", true);
$("#sterm").prop("disabled", true);
$("#slist").empty();
$("#pubs-spinner").show();
$.ajax({
type: "POST",
dataType: "json",
url: "https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/app/_search",
crossDomain: true,
data: JSON.stringify(dataset),
success: function(data) {
var hits = data.hits.hits;
if(search) {
$("#pubs-header-title").text("Public Servers - Search Results: " + hits.length);
} else {
$("#pubs-header-title").text("Public Servers");
}
hits.forEach(function(hit) {
var source = hit._source;
var icode = source.invite_code;
var html = '<div class="server-row">';
html += '<div class="server-icon" style="background-image:url(' + source.icon + ')"></div>';
html += '<div class="server-info server-name">';
html += '<span>' + source.name + ' by ' + source.owner.name + '</span>';
html += '</div>';
html += '<div class="server-info server-members">';
html += '<span>' + source.online + '/' + source.members + ' Members</span>';
html += '</div>';
html += '<div class="server-info server-region">';
html += '<span>' + source.region + '</span>';
html += '</div>';
html += '<div class="server-info">';
html += '<button data-server-invite-code='+icode+'>Join</button>';
html += '</div>';
html += '</div>';
$("#slist").append(html);
$("button[data-server-invite-code="+icode+"]").on("click", function(){
self.joinServer(icode);
});
});
},
done: function() {
$("#pubs-spinner").hide();
$("#sbtn").prop("disabled", false);
$("#sterm").prop("disabled", false);
},
always: function() {
$("#pubs-spinner").hide();
$("#sbtn").prop("disabled", false);
$("#sterm").prop("disabled", false);
},
error: function() {
$("#pubs-spinner").hide();
$("#sbtn").prop("disabled", false);
$("#sterm").prop("disabled", false);
},
complete: function() {
$("#pubs-spinner").hide();
$("#sbtn").prop("disabled", false);
$("#sterm").prop("disabled", false);
}
});
};
PublicServers.prototype.search = function() {
var dataset = {
"sort": [{
"online": "desc"
}],
"from": 0,
"size": 20,
"query": {
"filtered": {
"query": {
"match_all": {}
}
}
}
};
var filter = {
"filter": {
"and": [{
"query": {
"match_phrase_prefix": {
"name": $("#sterm").val()
}
}
}]
}
};
if ($("#sterm").val()) {
$.extend(dataset, filter);
}
this.loadServers(dataset, true);
}; };
//Workaround for joining a server //Workaround for joining a server

8
js/main.min.js vendored
View File

@ -1,4 +1,4 @@
var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule;var jsVersion=1.59;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},"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},"Show emote modifiers":{"id":"bda-es-8","info":"Enable/Disable emote mods","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-es-8":true,"bda-jd":true};var bdchangelog={"changes":{"api":{"title":"New plugin api callback","text":"Use the `observer(e)` callback instead of creating your own MutationObserver","img":""},"emotemods":{"title":"New emote mods!","text":"The following emote mods have been added: :shake2, :shake3, :flap","img":""},"minmode":{"title":"Minimal mode","text":"Minimal mode embed fixed size has been removed","img":""}},"fixes":{"emotes":{"title":"Native sub emote mods","text":"Emote mods now work with native sub emotes!","img":""},"emotes2":{"title":"Emote mods and custom emotes","text":"Emote mods will no longer interfere with custom emotes using :","img":""}}};var settingsCookie={};var bdaf=false;var bdafo=false;function Core(){} var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule;var jsVersion=1.6;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},"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},"Show emote modifiers":{"id":"bda-es-8","info":"Enable/Disable emote mods","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-es-8":true,"bda-jd":true};var bdchangelog={"changes":{"pslist":{"title":"v1.60 : New public server list!","text":'New and shiny public server list powered by <a href="https://www.discordservers.com/" target="_blank">DiscordServers.com</a>!',"img":""},"api":{"title":"v1.59 : New plugin api callback","text":"Use the `observer(e)` callback instead of creating your own MutationObserver","img":""},"emotemods":{"title":"v1.59 : New emote mods!","text":"The following emote mods have been added: :shake2, :shake3, :flap","img":""},"minmode":{"title":"v1.59: Minimal mode","text":"Minimal mode embed fixed size has been removed","img":""}},"fixes":{"emotes":{"title":"v1.59 : Native sub emote mods","text":"Emote mods now work with native sub emotes!","img":""},"emotes2":{"title":"v1.59 : Emote mods and custom emotes","text":"Emote mods will no longer interfere with custom emotes using :","img":""}}};var settingsCookie={};var bdaf=false;var bdafo=false;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();}
@ -26,8 +26,10 @@ if(subEmotesTwitch.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);v
if(typeof emotesFfz!=='undefined'&&settingsCookie["bda-es-1"]){if(emotesFfz.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=ffzEmoteUrlStart+emotesFfz[sWord]+ffzEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}} if(typeof emotesFfz!=='undefined'&&settingsCookie["bda-es-1"]){if(emotesFfz.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=ffzEmoteUrlStart+emotesFfz[sWord]+ffzEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}
if(typeof emotesBTTV!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=emotesBTTV[sWord];parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}} if(typeof emotesBTTV!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=emotesBTTV[sWord];parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}
if(typeof emotesBTTV2!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV2.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=bttvEmoteUrlStart+emotesBTTV2[sWord]+bttvEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}});if(parent.parentElement==null)return;var oldHeight=parent.parentElement.offsetHeight;parent.innerHTML=parentInnerHTML.replace(new RegExp("\uFDD9","g"),"");var newHeight=parent.parentElement.offsetHeight;var scrollPane=$(".scroller.messages").first();scrollPane.scrollTop(scrollPane.scrollTop()+(newHeight-oldHeight));} if(typeof emotesBTTV2!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV2.hasOwnProperty(sWord)){var len=Math.round(sWord.length / 4);var name=sWord.substr(0,len)+"\uFDD9"+sWord.substr(len,len)+"\uFDD9"+sWord.substr(len*2,len)+"\uFDD9"+sWord.substr(len*3);var url=bttvEmoteUrlStart+emotesBTTV2[sWord]+bttvEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote '+emoteClass+'" alt="'+name+'" src="'+url+'"/><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}});if(parent.parentElement==null)return;var oldHeight=parent.parentElement.offsetHeight;parent.innerHTML=parentInnerHTML.replace(new RegExp("\uFDD9","g"),"");var newHeight=parent.parentElement.offsetHeight;var scrollPane=$(".scroller.messages").first();scrollPane.scrollTop(scrollPane.scrollTop()+(newHeight-oldHeight));}
if(edited){setTimeout(inject,250);}else{inject();}};EmoteModule.prototype.autoCapitalize=function(){var self=this;$('body').delegate($(".channel-textarea-inner textarea"),'keyup change paste',function(){if(!settingsCookie["bda-es-4"])return;var text=$(".channel-textarea-inner textarea").val();if(text==undefined)return;var lastWord=text.split(" ").pop();if(lastWord.length>3){if(lastWord=="danSgame")return;var ret=self.capitalize(lastWord.toLowerCase());if(ret!==null&&ret!==undefined){$(".channel-textarea-inner textarea").val(text.replace(lastWord,ret));}}});};EmoteModule.prototype.capitalize=function(value){var res=emotesTwitch.emotes;for(var p in res){if(res.hasOwnProperty(p)&&value==(p+'').toLowerCase()){return p;}}};var publicServers={"servers":{"server":{"code":0,"icon":null,"title":"title","language":"EN","description":"description"}}};function PublicServers(){} if(edited){setTimeout(inject,250);}else{inject();}};EmoteModule.prototype.autoCapitalize=function(){var self=this;$('body').delegate($(".channel-textarea-inner textarea"),'keyup change paste',function(){if(!settingsCookie["bda-es-4"])return;var text=$(".channel-textarea-inner textarea").val();if(text==undefined)return;var lastWord=text.split(" ").pop();if(lastWord.length>3){if(lastWord=="danSgame")return;var ret=self.capitalize(lastWord.toLowerCase());if(ret!==null&&ret!==undefined){$(".channel-textarea-inner textarea").val(text.replace(lastWord,ret));}}});};EmoteModule.prototype.capitalize=function(value){var res=emotesTwitch.emotes;for(var p in res){if(res.hasOwnProperty(p)&&value==(p+'').toLowerCase()){return p;}}};function PublicServers(){}
PublicServers.prototype.getPanel=function(){return this.container;};PublicServers.prototype.init=function(){var self=this;this.container=$("<div/>",{id:"bd-ps-container",style:"display:none"});var header=$("<div/>",{id:"bd-ps-header"});$("<h2/>",{text:"Public Servers"}).appendTo(header);$("<span/>",{id:"bd-ps-close",style:"cursor:pointer;",text:"X"}).appendTo(header);header.appendTo(this.getPanel());var psbody=$("<div/>",{id:"bd-ps-body"});psbody.appendTo(this.getPanel());var table=$("<table/>",{border:"0"});var thead=$("<thead/>");thead.appendTo(table);var headers=$("<tr/>",{}).append($("<th/>",{text:"Name"})).append($("<th/>",{text:"Code"})).append($("<th/>",{text:"Language"})).append($("<th/>",{text:"Description"})).append($("<th/>",{text:"Join"}));headers.appendTo(thead);var tbody=$("<tbody/>",{id:"bd-ps-tbody"});tbody.appendTo(table);table.appendTo(psbody);$("body").append(this.getPanel());$("#bd-ps-close").on("click",function(){self.show();});var servers=publicServers.servers;for(var server in servers){if(servers.hasOwnProperty(server)){var s=servers[server];var code=s.code;var title=s.title;var language=s.language;var description=s.description;this.addServer(server,code,title,language,description);}}};PublicServers.prototype.addServer=function(name,code,title,language,description){var self=this;var tableBody=$("#bd-ps-tbody");var desc=$("<td/>").append($("<div/>",{class:"bd-ps-description",text:description}));var tr=$("<tr/>");tr.append($("<td/>",{text:title}));tr.append($("<td/>",{css:{"-webkit-user-select":"initial","user-select":"initial"},text:code}));tr.append($("<td/>",{text:language}));tr.append(desc);tr.append($("<td/>").append($("<button/>",{text:"Join",css:{"height":"30px","display":"block","margin-top":"10px","background-color":"#36393E","border":"1px solid #404040","outline":"1px solid #000","color":"#EDEDED"},click:function(){self.joinServer(code);}})));tableBody.append(tr);};PublicServers.prototype.show=function(){this.getPanel().toggle();var li=$("#bd-pub-li");li.removeClass();if(this.getPanel().is(":visible")){li.addClass("active");}};PublicServers.prototype.joinServer=function(code){$(".guilds-add").click();$(".action.join .btn").click();$(".create-guild-container input").val(code);$(".form.join-server .btn-primary").click();};var emoteBtn,emoteMenu;var eiarr=[1,3,4,6,7,8,10,11,12,13,14];function QuickEmoteMenu(){} PublicServers.prototype.getPanel=function(){return this.container;};PublicServers.prototype.init=function(){var panelBase="";panelBase+="<div id=\"pubs-container\">";panelBase+=" <div id=\"pubs-spinner\">";panelBase+=" <span class=\"spinner\" type=\"wandering-cubes\"><span class=\"spinner-inner spinner-wandering-cubes\"><span class=\"spinner-item\"><\/span><span class=\"spinner-item\"><\/span><\/span><\/span>";panelBase+=" <\/div>";panelBase+=" <div id=\"pubs-header\">";panelBase+=" <h2 id=\"pubs-header-title\">Public Servers<\/h2>";panelBase+=" <button id=\"sbtn\">Search<\/button>";panelBase+=" <input id=\"sterm\" type=\"text\" placeholder=\"Search term...\"\/>";panelBase+=" <\/div>";panelBase+=" <div class=\"scroller-wrap\">";panelBase+=" <div class=\"scroller\">";panelBase+=" <div id=\"slist\" class=\"servers-listing\">";panelBase+=" ";panelBase+=" <\/div>";panelBase+=" <\/div>";panelBase+=" <\/div>";panelBase+=" <div id=\"pubs-footer\">";panelBase+=" <div>Server list provided by <a href=\"https:\/\/www.discordservers.com\/\" target=\"_blank\">DiscordServers.com<\/a><\/div>";panelBase+=" <\/div>";panelBase+="<\/div>";this.container=panelBase;};PublicServers.prototype.show=function(){var self=this;$("body").append(this.getPanel());var dataset={"sort":[{"online":"desc"}],"from":0,"size":20,"query":{"filtered":{"query":{"match_all":{}}}}};$("#sbtn").on("click",function(){self.search();});$("#sterm").on("keyup",function(e){if(e.keyCode==13){self.search();}});this.loadServers(dataset,false);var self=this;$(document).on("mouseup.bdps",function(e){if(!$("#bd-pub-button").is(e.target)&&!$("#pubs-container").is(e.target)&&$("#pubs-container").has(e.target).length===0){self.hide();}});};PublicServers.prototype.hide=function(){$("#pubs-container").remove();$(document).off("mouseup.bdps");};PublicServers.prototype.loadServers=function(dataset,search){var self=this;$("#sbtn").prop("disabled",true);$("#sterm").prop("disabled",true);$("#slist").empty();$("#pubs-spinner").show();$.ajax({type:"POST",dataType:"json",url:"https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/app/_search",crossDomain:true,data:JSON.stringify(dataset),success:function(data){var hits=data.hits.hits;if(search){$("#pubs-header-title").text("Public Servers - Search Results: "+hits.length);}else{$("#pubs-header-title").text("Public Servers");}
hits.forEach(function(hit){var source=hit._source;var icode=source.invite_code;var html='<div class="server-row">';html+='<div class="server-icon" style="background-image:url('+source.icon+')"></div>';html+='<div class="server-info server-name">';html+='<span>'+source.name+' by '+source.owner.name+'</span>';html+='</div>';html+='<div class="server-info server-members">';html+='<span>'+source.online+'/'+source.members+' Members</span>';html+='</div>';html+='<div class="server-info server-region">';html+='<span>'+source.region+'</span>';html+='</div>';html+='<div class="server-info">';html+='<button data-server-invite-code='+icode+'>Join</button>';html+='</div>';html+='</div>';$("#slist").append(html);$("button[data-server-invite-code="+icode+"]").on("click",function(){self.joinServer(icode);});});},done:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);},always:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);},error:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);},complete:function(){$("#pubs-spinner").hide();$("#sbtn").prop("disabled",false);$("#sterm").prop("disabled",false);}});};PublicServers.prototype.search=function(){var dataset={"sort":[{"online":"desc"}],"from":0,"size":20,"query":{"filtered":{"query":{"match_all":{}}}}};var filter={"filter":{"and":[{"query":{"match_phrase_prefix":{"name":$("#sterm").val()}}}]}};if($("#sterm").val()){$.extend(dataset,filter);}
this.loadServers(dataset,true);};PublicServers.prototype.joinServer=function(code){$(".guilds-add").click();$(".action.join .btn").click();$(".create-guild-container input").val(code);$(".form.join-server .btn-primary").click();};var emoteBtn,emoteMenu;var eiarr=[1,3,4,6,7,8,10,11,12,13,14];function QuickEmoteMenu(){}
QuickEmoteMenu.prototype.init=function(reload){emoteBtn=null;$(".channel-textarea").first().removeClass("emotemenu-enabled");if(!emoteMenu){this.initEmoteList();} QuickEmoteMenu.prototype.init=function(reload){emoteBtn=null;$(".channel-textarea").first().removeClass("emotemenu-enabled");if(!emoteMenu){this.initEmoteList();}
var menuOpen;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);emoteMenu.detach();emoteBtn.append(emoteMenu);$("#twitchcord-button").on("click",function(){menuOpen=!menuOpen;if(menuOpen){$("#bdemotemenustyle").html('.twitchcord-button-open { background-image:url(https://static-cdn.jtvnw.net/emoticons/v1/'+eiarr[Math.floor(Math.random()*eiarr.length)]+'/1.0) !important; }');emoteMenu.addClass("emotemenu-open");$(this).addClass("twitchcord-button-open");}else{emoteMenu.removeClass();$(this).removeClass();} var menuOpen;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);emoteMenu.detach();emoteBtn.append(emoteMenu);$("#twitchcord-button").on("click",function(){menuOpen=!menuOpen;if(menuOpen){$("#bdemotemenustyle").html('.twitchcord-button-open { background-image:url(https://static-cdn.jtvnw.net/emoticons/v1/'+eiarr[Math.floor(Math.random()*eiarr.length)]+'/1.0) !important; }');emoteMenu.addClass("emotemenu-open");$(this).addClass("twitchcord-button-open");}else{emoteMenu.removeClass();$(this).removeClass();}
return false;});$(document).off("click.bdem").on("click.bdem",function(){if(menuOpen){menuOpen=!menuOpen;emoteMenu.removeClass();$("#twitchcord-button").removeClass();}});$("#emote-menu").on("click",function(){$("#rmenu").hide();return false;});if(settingsCookie["bda-es-0"]){$(".channel-textarea").first().addClass("emotemenu-enabled");emoteBtn.show();} return false;});$(document).off("click.bdem").on("click.bdem",function(){if(menuOpen){menuOpen=!menuOpen;emoteMenu.removeClass();$("#twitchcord-button").removeClass();}});$("#emote-menu").on("click",function(){$("#rmenu").hide();return false;});if(settingsCookie["bda-es-0"]){$(".channel-textarea").first().addClass("emotemenu-enabled");emoteBtn.show();}