BetterDiscordApp-v1/js/main.min.js

2 lines
56 KiB
JavaScript

function Core(){}function EmoteModule(){}function PublicServers(){}function QuickEmoteMenu(){}function CustomCssEditor(){}function SettingsPanel(){utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/codemirror.min.js"),utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/mode/css/css.min.js"),utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.2/Sortable.min.js")}function Utils(){}function VoiceMode(){}function PluginModule(){}function ThemeModule(){}function BdWSocket(){bdws=this}function BdApi(){}function devMode(){}var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule,customCssEditor,dMode,jsVersion=1.73,supportedVersion="0.2.5",mainObserver,twitchEmoteUrlStart="https://static-cdn.jtvnw.net/emoticons/v1/",twitchEmoteUrlEnd="/1.0",ffzEmoteUrlStart="https://cdn.frankerfacez.com/emoticon/",ffzEmoteUrlEnd="/1",bttvEmoteUrlStart="https://cdn.betterttv.net/emote/",bttvEmoteUrlEnd="/1x",mainCore,settings={"Save logs locally":{id:"bda-gs-0",info:"Saves chat logs locally",implemented:!1,hidden:!1,cat:"core"},"Public Servers":{id:"bda-gs-1",info:"Display public servers button",implemented:!0,hidden:!1,cat:"core"},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0,hidden:!1,cat:"core"},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0,hidden:!1,cat:"core"},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0,hidden:!1,cat:"core"},"Dark Mode":{id:"bda-gs-5",info:"Make certain elements dark by default(wip)",implemented:!0,hidden:!1,cat:"core"},"Override Default Emotes":{id:"bda-es-5",info:"Override default emotes",implemented:!1,hidden:!1,cat:"core"},"Voice Disconnect":{id:"bda-dc-0",info:"Disconnect from voice server when closing Discord",implemented:!0,hidden:!1,cat:"core"},"Custom css live update":{id:"bda-css-0",info:"",implemented:!0,hidden:!0,cat:"core"},"Custom css auto udpate":{id:"bda-css-1",info:"",implemented:!0,hidden:!0,cat:"core"},"24 Hour Timestamps":{id:"bda-gs-6",info:"Replace 12hr timestamps with proper ones",implemented:!0,hidden:!1,cat:"core"},"Coloured Text":{id:"bda-gs-7",info:"Make text colour the same as role colour",implemented:!0,hidden:!1,cat:"core"},"Developer Mode":{id:"bda-gs-8",info:"Developer Mode",implemented:!0,hidden:!1,cat:"core"},"Twitch Emotes":{id:"bda-es-7",info:"Show Twitch emotes",implemented:!0,hidden:!1,cat:"emote"},"FrankerFaceZ Emotes":{id:"bda-es-1",info:"Show FrankerFaceZ Emotes",implemented:!0,hidden:!1,cat:"emote"},"BetterTTV Emotes":{id:"bda-es-2",info:"Show BetterTTV Emotes",implemented:!0,hidden:!1,cat:"emote"},"Emote Menu":{id:"bda-es-0",info:"Show Twitch/Favourite emotes in emote menu",implemented:!0,hidden:!1,cat:"emote"},"Emoji Menu":{id:"bda-es-9",info:"Show Discord emoji menu",implemented:!0,hidden:!1,cat:"emote"},"Emote Autocomplete":{id:"bda-es-3",info:"Autocomplete emote commands",implemented:!1,hidden:!1,cat:"emote"},"Emote Auto Capitalization":{id:"bda-es-4",info:"Autocapitalize emote commands",implemented:!0,hidden:!1,cat:"emote"},"Show Names":{id:"bda-es-6",info:"Show emote names on hover",implemented:!0,hidden:!1,cat:"emote"},"Show emote modifiers":{id:"bda-es-8",info:"Enable emote mods",implemented:!0,hidden:!1,cat:"emote"}},links={"Jiiks.net":{text:"Jiiks.net",href:"thtp://jiiks.net",target:"_blank"},twitter:{text:"Twitter",href:"http://twitter.com/jiiksi",target:"_blank"},github:{text:"Github",href:"http://github.com/jiiks",target:"_blank"}},defaultCookie={version:jsVersion,"bda-gs-0":!1,"bda-gs-1":!0,"bda-gs-2":!1,"bda-gs-3":!1,"bda-gs-4":!1,"bda-gs-5":!0,"bda-gs-6":!1,"bda-gs-7":!1,"bda-gs-8":!1,"bda-es-0":!0,"bda-es-1":!0,"bda-es-2":!0,"bda-es-3":!1,"bda-es-4":!1,"bda-es-5":!0,"bda-es-6":!0,"bda-es-7":!0,"bda-es-8":!0,"bda-jd":!0,"bda-es-8":!0,"bda-dc-0":!1,"bda-css-0":!1,"bda-css-1":!1,"bda-es-9":!0},bdchangelog={changes:{"0a":{title:"1.73 : Native sub emotes",text:"Native sub emote support disabled for now due to a critical bug",img:""},"1a":{title:"1.73 : Initial Developer Mode",text:"Enable developer mode from settings!",img:""},a:{title:"v1.72 : Public Servers",text:"Public servers now have categories, description, tags, dark mode and more!",img:""},b:{title:"v1.72 : Import/Export",text:"Import/Export buttons now disappear in themes/plugins tabs to avoid confusion",img:""},c:{title:"v1.72 : Changelog",text:"You can now reopen this changelog from the settings",img:""},d:{title:"v1.71 : Hide Twitch emotes",text:"Hide all emotes option now toggles Twitch emotes instead!",img:""},e:{title:"v1.71 : Override FFZ emote",text:'Use the <code class="inline">:bttv</code> emote modifier to override a FFZ emote with a BTTV one!',img:""},f:{title:"v1.70 : 0.2.8 Support",text:"Added support for Core version 0.2.8.",img:""},g:{title:"v1.70 : Setting Import/Export",text:"You can now import and export your settings!",img:""},h:{title:"v1.70 : Public Server List Infinite Scroll",text:"Public server list now has the ability to load more than 20 servers.",img:""},i:{title:"v1.70 : 24 hour timestamps",text:"Replace 12 hour timestamp with 24 hour timestamps!",img:""},j:{title:"v1.70 : Coloured text",text:"Make text colour the same as role colour!",img:""}},fixes:{a:{title:"v1.72 : Settings panel",text:"Settings panel will now show no matter how you open it!",img:""},b:{title:"v1.72 : Fixed emote edit bug",text:"Edits now appear properly even with emotes!",img:""},c:{title:"v1.72 : Public servers",text:"Public servers button is visible again!",img:""},d:{title:"v1.72 : Public servers",text:"Updated public servers api endpoint url for fetching correct serverlist.",img:""},e:{title:"v1.71 : Fixed emotes and edit",text:"Emotes work again! So does editing emotes!",img:""},f:{title:"Spoilers are currently broken :(",text:"Ps. I know this in the fixes section :o",img:""}}},settingsCookie={};Core.prototype.init=function(){function a(){if(console.log((new Date).getTime()+" Defer"),$(".guilds-wrapper .guilds").children().length>0){console.log((new Date).getTime()+" Defer Loaded");var c=($(".guilds>li:first-child"),$("<button/>",{class:"btn",id:"bd-show-channels",text:"R",css:{cursor:"pointer"},click:function(){settingsCookie["bda-gs-3"]=!1,$("body").removeClass("bd-minimal-chan"),b.saveSettings()}}));if($(".guilds-wrapper").prepend(c),opublicServers=new PublicServers,customCssEditor=new CustomCssEditor,pluginModule=new PluginModule,pluginModule.loadPlugins(),"undefined"!=typeof themesupport2&&(themeModule=new ThemeModule,themeModule.loadThemes()),settingsPanel=new SettingsPanel,settingsPanel.init(),quickEmoteMenu.init(!1),$("#tc-settings-button").on("click",function(){settingsPanel.show()}),window.addEventListener("beforeunload",function(){settingsCookie["bda-dc-0"]&&$(".btn.btn-disconnect").click()}),$(document).on("mousedown",function(a){}),opublicServers.init(),emoteModule.autoCapitalize(),settingsCookie.version<jsVersion){var d=b.constructChangelog();$("body").append(d),settingsCookie.version=jsVersion,b.saveSettings()}$("head").append("<style>.CodeMirror{ min-width:100%; }</style>"),$("head").append('<style id="bdemotemenustyle"></style>')}else setTimeout(a,100)}var b=this,c="undefined"==typeof version?bdVersion:version;if(supportedVersion>c)return void this.alert("Not Supported","BetterDiscord v"+c+"(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>");utils=new Utils;var d=new BdWSocket;d.start(),utils.getHash(),emoteModule=new EmoteModule,quickEmoteMenu=new QuickEmoteMenu,voiceMode=new VoiceMode,dMode=new devMode,emoteModule.init(),this.initSettings(),this.initObserver(),$(document).ready(function(){setTimeout(a,1e3)})},Core.prototype.initSettings=function(){if(void 0==$.cookie("better-discord"))settingsCookie=defaultCookie,this.saveSettings();else{this.loadSettings();for(var a in defaultCookie)void 0==settingsCookie[a]&&(settingsCookie[a]=defaultCookie[a],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(a){a.forEach(function(a){if(void 0!==settingsPanel&&settingsPanel.inject(a),$(a.target).find(".emoji-picker").length){var b=a.target.firstChild;b.classList.contains("popout")&&quickEmoteMenu.obsCallback($(b))}"undefined"!=typeof pluginModule&&pluginModule.rawObserver(a),null!=a.target.getAttribute("class")&&((a.target.classList.contains("title-wrap")||a.target.classList.contains("chat"))&&(voiceMode.obsCallback(),"undefined"!=typeof pluginModule&&pluginModule.channelSwitch()),-1!=a.target.getAttribute("class").indexOf("scroller messages")&&"undefined"!=typeof pluginModule&&pluginModule.newMessage(),settingsCookie["bda-gs-6"]&&$(".timestamp").not("[data-24]").each(function(){var a=$(this);a.attr("data-24",!0);var b=a.text(),c=/(.*)?at\s+(\d{1,2}):(\d{1,2})\s+(.*)/.exec(b);if(null==c)return!0;if(c.length<5)return!0;var d=parseInt(c[2]);"AM"==c[4]?12==d&&(d-=12):"PM"==c[4]&&12>d&&(d+=12),c[2]=("0"+d).slice(-2),a.text(c[1]+" at "+c[2]+":"+c[3])}),settingsCookie["bda-gs-7"]&&$(".user-name").not("[data-colour]").each(function(){var a=$(this),b=a.css("color");return"rgb(255, 255, 255)"==b?!0:void a.closest(".message-group").find(".markup").not("[data-colour]").each(function(){$(this).attr("data-colour",!0),$(this).css("color",b)})})),emoteModule.obsCallback(a)})}),mainObserver.observe(document,{childList:!0,subtree:!0})},Core.prototype.constructChangelog=function(){var a='<div id="bd-wn-modal" class="modal" style="opacity:1;"> <div class="modal-inner"> <div id="bdcl" class="markdown-modal change-log"> <div class="markdown-modal-header"> <strong>What\'s new in BetterDiscord JS'+jsVersion+'</strong> <button class="markdown-modal-close" onclick=\'$("#bd-wn-modal").remove();\'></button> </div><!--header--> <div class="scroller-wrap"> <div class="scroller">';if(null!=bdchangelog.changes){a+='<h1 class="changelog-added"> <span>New Stuff</span></h1><ul>';for(var b in bdchangelog.changes)b=bdchangelog.changes[b],a+="<li> <strong>"+b.title+"</strong> <div>"+b.text+"</div></li>";a+="</ul>"}if(null!=bdchangelog.fixes){a+='<h1 class="changelog-fixed"> <span>Fixed</span></h1><ul>';for(var c in bdchangelog.fixes)c=bdchangelog.fixes[c],a+="<li> <strong>"+c.title+"</strong> <div>"+c.text+"</div></li>";a+="</ul>"}if(null!=bdchangelog.upcoming){a+='<h1 class="changelog-in-progress"> <span>Coming Soon</span></h1><ul>';for(var d in bdchangelog.upcoming)d=bdchangelog.upcoming[d],a+="<li> <strong>"+d.title+"</strong> <div>"+d.text+"</div></li>";a+="</ul>"}return a+=' </div><!--scoller--> </div><!--scroller-wrap--> <div class="footer"> </div><!--footer--> </div><!--change-log--> </div><!--modal-inner--></div><!--modal-->'},Core.prototype.alert=function(a,b){for(var c="",d=0;5>d;d++)c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(Math.random()*"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".length));var e=' <div id="bda-alert-'+c+'" class="modal bda-alert" style="opacity:1" data-bdalert="'+c+'"> <div class="modal-inner" style="box-shadow:0 0 8px -2px #000;"> <div class="markdown-modal"> <div class="markdown-modal-header"> <strong style="float:left"><span>BetterDiscord - </span><span>'+a+'</span></strong> <span></span> <button class="markdown-modal-close" onclick=\'document.getElementById("bda-alert-'+c+'").remove(); utils.removeBackdrop("'+c+'");\'></button> </div> <div class="scroller-wrap fade"> <div style="font-weight:700" class="scroller">'+b+'</div> </div> <div class="markdown-modal-footer"> <span style="float:right"> for support.</span> <a style="float:right" href="https://discord.gg/0Tmfo5ZbOR9NxvDd" target="_blank">#support</a> <span style="float:right">Join </span> </div> </div> </div> </div> ';$("body").append(e),utils.addBackdrop(c)};var emotesFfz={},emotesBTTV={},emotesTwitch={emotes:{emote:{image_id:0}}},subEmotesTwitch={};EmoteModule.prototype.init=function(){},EmoteModule.prototype.getBlacklist=function(){$.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/"+_hash+"/data/emotefilter.json",function(a){bemotes=a.blacklist})},EmoteModule.prototype.obsCallback=function(a){for(var b=this,c=0;c<a.addedNodes.length;++c){var d=a.addedNodes.item(c);if(d){var e=b.getNodes(d);for(var f in e)if(e.hasOwnProperty(f)){var g=e[f].parentElement;g&&g.classList.contains("edited")?b.injectEmote(g):b.injectEmote(e[f])}}}},EmoteModule.prototype.getNodes=function(a){for(var b,c=[],d=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1);b=d.nextNode();)c.push(b);return c};var bemotes=[],spoilered=[];EmoteModule.prototype.injectEmote=function(a){function b(){var a=d.contents();a.each(function(b){if(void 0!=a[b]){var e=a[b].nodeValue;if(null!=e&&8!=a[b].nodeType){a.splice(b,1);var f=e.split(/([^\s]+)([\s]|$)/g).filter(function(a){return a}),g=0,h=!1,i=null;if(f.forEach(function(e,f,j){e.indexOf("[!s]")>-1&&(e=e.replace("[!s]",""),d.data("spoilered",!1),d.addClass("spoiler"));var k=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],l="",m=!1,n=e;if(e.indexOf(":")>-1){var o=e.split(":");""!=o[0]&&""!=o[1]&&(k.indexOf(o[1])>-1&&(n=o[0],l=settingsCookie["bda-es-8"]?"emote"+o[1]:""),"bttv"==o[1]&&(n=o[0],m=!0))}if(-1==$.inArray(n,bemotes)){if("undefind"!=typeof emotesTwitch&&settingsCookie["bda-es-7"]&&emotesTwitch.emotes.hasOwnProperty(n)&&n.length>=4){null!=i&&(a.splice(b+g++,0,document.createTextNode(i)),i=null);var p=twitchEmoteUrlStart+emotesTwitch.emotes[n].image_id+twitchEmoteUrlEnd;return a.splice(b+g++,0,c.createEmoteElement(n,p,l)),void(h=!0)}if("undefined"!=typeof subEmotesTwitch&&settingsCookie["bda-es-7"]&&subEmotesTwitch.hasOwnProperty(n)&&n.length>=4){null!=i&&(a.splice(b+g++,0,document.createTextNode(i)),i=null);var p=twitchEmoteUrlStart+subEmotesTwitch[n]+twitchEmoteUrlEnd;return a.splice(b+g++,0,c.createEmoteElement(n,p,l)),void(h=!0)}if("undefined"!=typeof emotesBTTV&&settingsCookie["bda-es-2"]&&emotesBTTV.hasOwnProperty(n)&&n.length>=4){null!=i&&(a.splice(b+g++,0,document.createTextNode(i)),i=null);var p=emotesBTTV[n];return a.splice(b+g++,0,c.createEmoteElement(n,p,l)),void(h=!0)}if("undefined"!=typeof emotesFfz&&settingsCookie["bda-es-1"]&&(!m||!emotesBTTV2.hasOwnProperty(n))&&emotesFfz.hasOwnProperty(n)&&n.length>=4){null!=i&&(a.splice(b+g++,0,document.createTextNode(i)),i=null);var p=ffzEmoteUrlStart+emotesFfz[n]+ffzEmoteUrlEnd;return a.splice(b+g++,0,c.createEmoteElement(n,p,l)),void(h=!0)}if("undefined"!=typeof emotesBTTV2&&settingsCookie["bda-es-2"]&&emotesBTTV2.hasOwnProperty(n)&&n.length>=4){null!=i&&(a.splice(b+g++,0,document.createTextNode(i)),i=null);var p=bttvEmoteUrlStart+emotesBTTV2[n]+bttvEmoteUrlEnd;return m&&emotesFfz.hasOwnProperty(n)&&(n+=":bttv"),a.splice(b+g++,0,c.createEmoteElement(n,p,l)),void(h=!0)}}null==i?i=e:i+=""+e,f===j.length-1&&a.splice(b+g,0,document.createTextNode(i))}),h){var j=d.outerHeight();d.html(a);var k=$(".scroller.messages").first();k.scrollTop(k.scrollTop()+(d.outerHeight()-j))}}}})}var c=this;if(a.parentElement){var d=$(a).parent();(d.hasClass("markup")||d.hasClass("message-content"))&&(b(),d.children().hasClass("edited")&&setTimeout(b,250))}},EmoteModule.prototype.createEmoteElement=function(a,b,c){var d=Math.round(a.length/4),e=a.substr(0,d)+"﷙"+a.substr(d,d)+"﷙"+a.substr(2*d,d)+"﷙"+a.substr(3*d),f='<span class="emotewrapper"><img draggable="false" style="max-height:32px;" class="emote '+c+'" alt="'+e+'" src="'+b+'"/><input onclick=\'quickEmoteMenu.favorite("'+e+'", "'+b+'");\' class="fav" title="Favorite!" type="button"></span>';return $.parseHTML(f.replace(new RegExp("﷙","g"),""))[0]},EmoteModule.prototype.autoCapitalize=function(){var a=this;$("body").delegate($(".channel-textarea-inner textarea:first"),"keyup change paste",function(){if(settingsCookie["bda-es-4"]){var b=$(".channel-textarea-inner textarea:first").val();if(void 0!=b){var c=b.split(" ").pop();if(c.length>3){if("danSgame"==c)return;var d=a.capitalize(c.toLowerCase());null!==d&&void 0!==d&&$(".channel-textarea-inner textarea:first").val(b.replace(c,d))}}}})},EmoteModule.prototype.capitalize=function(a){var b=emotesTwitch.emotes;for(var c in b)if(b.hasOwnProperty(c)&&a==(c+"").toLowerCase())return c},PublicServers.prototype.getPanel=function(){return this.container},PublicServers.prototype.init=function(){this.filtered=["134680912691462144","86004744966914048"],this.bdServer=null,this.loadingServers=!1;var a=this,b=$(".guilds>:first-child");b.after($("<div></div>",{class:"guild",id:"bd-pub-li",css:{height:"20px",display:1==settingsCookie["bda-gs-1"]?"":"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"}))))),$("#bd-pub-button").on("click",function(){a.show()});var c=' <div id="pubs-container"> <div id="pubs-spinner"> <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> </div> <div id="pubs-header"> <h2 id="pubs-header-title">Public Servers</h2> <button id="pubs-searchbtn">Search</button> <input id="pubs-sterm" type="text" placeholder="Search Term..."> <div id="pubs-select-dropdown" class="bd-dropdown"> <button class="bd-dropdown-select" id="pubs-cat-select">All</button> <div class="bd-dropdown-list"> <ul> <li class="pubs-cat-select-li" data-val="all">All</li> <li class="pubs-cat-select-li" data-val="1">FPS Games</li> <li class="pubs-cat-select-li" data-val="2">MMO Games</li> <li class="pubs-cat-select-li" data-val="3">MOBA Games</li> <li class="pubs-cat-select-li" data-val="4">Strategy Games</li> <li class="pubs-cat-select-li" data-val="5">Sports Games</li> <li class="pubs-cat-select-li" data-val="6">Puzzle Games</li> <li class="pubs-cat-select-li" data-val="7">Retro Games</li> <li class="pubs-cat-select-li" data-val="8">Party Games</li> <li class="pubs-cat-select-li" data-val="9">Tabletop Games</li> <li class="pubs-cat-select-li" data-val="10">Sandbox Games</li> <li class="pubs-cat-select-li" data-val="11">Community</li> <li class="pubs-cat-select-li" data-val="12">Language</li> <li class="pubs-cat-select-li" data-val="13">Programming</li> <li class="pubs-cat-select-li" data-val="14">Other</li> <li class="pubs-cat-select-li" data-val="15">Simulation Games</li> </ul> </div> </div> </div> <div class="server-row server-pinned" style="display:none;"> <div class="server-icon" style="background-image:url(https://cdn.discordapp.comi/cons/86004744966914048/6e5729ed5c12d5af558d80d7a194c3f9.jpg)"></div> <div class="server-info server-name"><span>BetterDiscord</span><span id="server-bd-tag">Official BetterDiscord server</span></div> <div class="server-info server-members"><span></span></div> <div class="server-info server-region"><span></span></div> <div class="server-info"> <button data-server-invite-code="0Tmfo5ZbORCRqbAd">Join</button> </div> </div> <div class="scroller-wrap"> <div class="scroller" id="pubs-scroller"> <div id="pubs-list" class="servers-listing"> </div> <div style="background:#FFF; padding: 5px 0; display:none;" id="pubs-spinner-bottom"> <div> <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> </div> </div> </div> </div> <div id="pubs-footer"> <span style="color:#FFF; font-size:10px; font-weight:700; margin-left:5px;">Tip: Hover over server name for description if available</span> <div>Server list provided by <a href="https://discordservers.com" target="_blank">DiscordServers.com</a></div> </div> ';this.container=c,$("#bd-pub-li").length<1&&setTimeout(function(){a.init()},250)},PublicServers.prototype.getPinnedServer=function(){var a=this,b={sort:[{online:"desc"}],size:1,query:{query_string:{default_operator:"AND",query:"BetterDiscord"}}};$.ajax({type:"POST",dataType:"json",url:"https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/discord_servers/_search",crossDomain:!0,data:JSON.stringify(b),success:function(b){try{var c=b.hits.hits[0]._source;"86004744966914048"==c.identifier&&(a.bdServer=c,a.showPinnedServer())}catch(b){a.bdServer=null}}})},PublicServers.prototype.hidePinnedServer=function(){$("#pubs-container .scroller-wrap").css({"margin-top":"0",height:"500px"}),$(".server-pinned").hide()},PublicServers.prototype.showPinnedServer=function(){$(".server-pinned .server-icon").css("background-image","url("+this.bdServer.icon+")"),$(".server-pinned .server-members span").text(this.bdServer.online+"/"+this.bdServer.members+" Members"),$(".server-pinned .server-region span").text(this.bdServer.region),$(".server-pinned .server-info button").data("server-invite-code",this.bdServer.invite_code),$("#pubs-container .scroller-wrap").css({"margin-top":"75px",height:"425px"}),$(".server-pinned").show()},PublicServers.prototype.show=function(){var a=this;this.hidePinnedServer(),$("#pubs-cat-select").text("All"),this.selectedCategory="all",$("#pubs-container .scroller-wrap").css({"margin-top":"0",height:"500px"}),$(".server-pinned").hide(),$(".app").append(this.getPanel()),null==this.bdServer?this.getPinnedServer():this.showPinnedServer(),a.search(0,!0),$("#pubs-searchbtn").off("click").on("click",function(){a.search()}),$("#pubs-sterm").off("keyup").on("keyup",function(b){13==b.keyCode&&a.search(0,!0)}),$("#pubs-cat-select").off("click").on("click",function(){$("#pubs-select-dropdown").addClass("open")}),$(".pubs-cat-select-li").off("click").on("click",function(){$("#pubs-select-dropdown").removeClass("open"),$("#pubs-cat-select").text($(this).text()),a.selectedCategory!=$(this).data("val")&&(a.selectedCategory=$(this).data("val"),a.search(0,!0))}),$("#pubs-container").off("mouseup").on("mouseup",function(){$("#pubs-select-dropdown").removeClass("open")});var a=this;$(document).on("mouseup.bdps",function(b){$("#bd-pub-button").is(b.target)||$("#pubs-container").is(b.target)||0!==$("#pubs-container").has(b.target).length||a.hide()}),$("#pubs-scroller").off("scroll.pubs").on("scroll.pubs",function(){if(!a.loadingServers){var b=$("#pubs-list");$(this).scrollTop()+550<b.height()||b.children().length%20==0&&(a.loadingServers=!0,$("#pubs-spinner-bottom").show(),a.search(b.children().length,!1))}})},PublicServers.prototype.hide=function(){$("#pubs-container").remove(),$(document).off("mouseup.bdps")},PublicServers.prototype.loadServers=function(a,b,c){this.loadingServers=!0;var d=this;$("#pubs-searchbtn").prop("disabled",!0),$("#pubs-sterm").prop("disabled",!0),c&&$("#pubs-list").empty(),$("#pubs-spinner").show(),$.ajax({type:"POST",dataType:"json",url:"https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/discord_servers/_search",crossDomain:!0,data:JSON.stringify(a),success:function(a){var c=a.hits.hits;b?$("#pubs-header-title").text("Public Servers - Search Results: "+c.length):$("#pubs-header-title").text("Public Servers"),c.forEach(function(a){var b=a._source,c=b.invite_code.replace(/ /g,""),e='<div class="server-row">';e+='<div class="server-icon" style="background-image:url('+b.icon+')"></div>',e+='<div class="server-info server-name">',e+='<div class="server-information">',b.is_official&&(e+='<span class="server-official">Official!</span>'),e+='<span class="server-name-span">'+b.name+"</span>";var f=[];b.categories.forEach(function(a){f.push(a.name)}),e+='<span class="server-tags">'+f.join(", ")+"</span>",e+='<span class="server-description">'+(void 0==b.description?"No Description":b.description)+"</span>",e+="</div>",e+="</div>",e+='<div class="server-info server-members">',e+="<span>"+b.online+"/"+b.members+" Members</span>",e+="</div>",e+='<div class="server-info server-region">',e+="<span>"+b.region+"</span>",e+="</div>",e+='<div class="server-info">',e+="<button data-server-invite-code="+c+">Join</button>",e+="</div>",e+="</div>",$("#pubs-list").append(e),$("button[data-server-invite-code="+c+"]").on("click",function(){d.joinServer(c)})}),b&&$("#pubs-header-title").text("Public Servers - Search Results: "+$("#pubs-list").children().length)},done:function(){$("#pubs-spinner").hide(),$("#pubs-spinner-bottom").hide(),$("#pubs-searchbtn").prop("disabled",!1),$("#pubs-sterm").prop("disabled",!1),d.loadingServers=!1},always:function(){$("#pubs-spinner").hide(),$("#pubs-spinner-bottom").hide(),$("#pubs-searchbtn").prop("disabled",!1),$("#pubs-sterm").prop("disabled",!1),d.loadingServers=!1},error:function(){$("#pubs-spinner").hide(),$("#pubs-spinner-bottom").hide(),$("#pubs-searchbtn").prop("disabled",!1),$("#pubs-sterm").prop("disabled",!1),d.loadingServers=!1},complete:function(){$("#pubs-spinner").hide(),$("#pubs-spinner-bottom").hide(),$("#pubs-searchbtn").prop("disabled",!1),$("#pubs-sterm").prop("disabled",!1),d.loadingServers=!1}})},PublicServers.prototype.search=function(a,b){var c=$("#pubs-sterm").val(),d={sort:[{online:"desc"}],from:a,size:20,query:{filtered:{query:{query_string:{default_operator:"AND",query:c?c:"*"}},filter:{bool:{must_not:[{terms:{identifier:this.filtered}}]}}}}};"all"!=this.selectedCategory&&(d.query.filtered.filter.bool.must=[{term:{"categories.id":this.selectedCategory}}]),this.loadServers(d,!0,b)},PublicServers.prototype.joinServer=function(a){$(".guilds-add").click(),$(".action.join .btn").click(),$(".create-guild-container input").val(a),$(".form.join-server .btn-primary").click()},QuickEmoteMenu.prototype.init=function(){$(document).on("mousedown",function(a){"rmenu"!=a.target.id&&$("#rmenu").remove()}),this.favoriteEmotes={};var a=localStorage.bdfavemotes;void 0!=a&&(this.favoriteEmotes=JSON.parse(atob(a)));var b="";b+='<div id="bda-qem">',b+=' <button class="active" id="bda-qem-twitch" onclick=\'quickEmoteMenu.switchHandler(this); return false;\'>Twitch</button>',b+=" <button id=\"bda-qem-favourite\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Favourite</button>",b+=" <button id=\"bda-qem-emojis\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Emojis</buttond>",b+="</div>",this.qmeHeader=b;var c="";c+='<div id="bda-qem-twitch-container">',c+=' <div class="scroller-wrap fade">',c+=' <div class="scroller">',c+=' <div class="emote-menu-inner">';for(var d in emotesTwitch.emotes)if(emotesTwitch.emotes.hasOwnProperty(d)){var e=emotesTwitch.emotes[d].image_id;c+='<div class="emote-container">',c+=' <img class="emote-icon" id="'+d+'" alt="" src="https://static-cdn.jtvnw.net/emoticons/v1/'+e+'/1.0" title="'+d+'">',c+=" </img>",c+="</div>"}c+=" </div>",c+=" </div>",c+=" </div>",c+="</div>",this.teContainer=c;var f="";f+='<div id="bda-qem-favourite-container">',f+=' <div class="scroller-wrap fade">',f+=' <div class="scroller">',f+=' <div class="emote-menu-inner">';for(var d in this.favoriteEmotes){var g=this.favoriteEmotes[d];f+='<div class="emote-container">',f+=' <img class="emote-icon" alt="" src="'+g+'" title="'+d+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",f+=" </img>",f+="</div>"}f+=" </div>",f+=" </div>",f+=" </div>",f+="</div>",this.faContainer=f},QuickEmoteMenu.prototype.favContext=function(a,b){a.stopPropagation();var c=$("<div/>",{id:"rmenu","data-emoteid":$(b).prop("title"),text:"Remove"});return c.css({top:a.pageY-$("#bda-qem-favourite-container").offset().top,left:a.pageX-$("#bda-qem-favourite-container").offset().left}),$(b).parent().append(c),c.on("click",function(a){return a.preventDefault(),a.stopPropagation(),$(this).remove(),delete quickEmoteMenu.favoriteEmotes[$(this).data("emoteid")],quickEmoteMenu.updateFavorites(),!1}),!1},QuickEmoteMenu.prototype.switchHandler=function(a){this.switchQem($(a).attr("id"))},QuickEmoteMenu.prototype.switchQem=function(a){var b=$("#bda-qem-twitch"),c=$("#bda-qem-favourite"),d=$("#bda-qem-emojis");switch(b.removeClass("active"),c.removeClass("active"),d.removeClass("active"),$(".emoji-picker").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),a){case"bda-qem-twitch":b.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":c.addClass("active"),$("#bda-qem-favourite-container").show();break;case"bda-qem-emojis":d.addClass("active"),$(".emoji-picker").show()}this.lastTab=a;var e=$(".emote-icon");e.off(),e.on("click",function(){var a=$(this).attr("title"),b=$(".channel-textarea-inner textarea");b.val(" "==b.val().slice(-1)?b.val()+a:b.val()+" "+a)})},QuickEmoteMenu.prototype.obsCallback=function(a){if(settingsCookie["bda-es-9"]?a.removeClass("bda-qme-hidden"):a.addClass("bda-qme-hidden"),settingsCookie["bda-es-0"]){a.prepend(this.qmeHeader),a.append(this.teContainer),a.append(this.faContainer),void 0==this.lastTab&&(this.lastTab="bda-qem-favourite"),this.switchQem(this.lastTab)}},QuickEmoteMenu.prototype.favorite=function(a,b){this.favoriteEmotes.hasOwnProperty(a)||(this.favoriteEmotes[a]=b),this.updateFavorites()},QuickEmoteMenu.prototype.updateFavorites=function(){var a="";a+='<div id="bda-qem-favourite-container">',a+=' <div class="scroller-wrap fade">',a+=' <div class="scroller">',a+=' <div class="emote-menu-inner">';for(var b in this.favoriteEmotes){var c=this.favoriteEmotes[b];a+='<div class="emote-container">',a+=' <img class="emote-icon" alt="" src="'+c+'" title="'+b+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",a+=" </img>",a+="</div>"}a+=" </div>",a+=" </div>",a+=" </div>",a+="</div>",this.faContainer=a,$("#bda-qem-favourite-container").replaceWith(a),window.localStorage.bdfavemotes=btoa(JSON.stringify(this.favoriteEmotes))},CustomCssEditor.prototype.init=function(){var a=this;a.hideBackdrop=!1,a.editor=CodeMirror.fromTextArea(document.getElementById("bd-custom-css-ta"),{
lineNumbers:!0,mode:"css",indentUnit:4,theme:"neat"}),a.editor.on("change",function(b){var c=b.getValue();a.applyCustomCss(c,!1,!1)});var b="";b+='<div id="bd-customcss-attach-controls">',b+=' <ul class="checkbox-group">',b+=" <li>",b+=' <div class="checkbox" onclick="settingsPanel.updateSetting(this);">',b+=' <div class="checkbox-inner"><input id="bda-css-0" type="checkbox" '+(settingsCookie["bda-css-0"]?"checked":"")+"><span></span></div>",b+=' <span title="Update client css while typing">Live Update</span>',b+=" </div>",b+=" </li>",b+=" <li>",b+=' <div class="checkbox" onclick="settingsPanel.updateSetting(this);">',b+=' <div class="checkbox-inner"><input id="bda-css-1" type="checkbox" '+(settingsCookie["bda-css-1"]?"checked":"")+"><span></span></div>",b+=' <span title="Autosave css to localstorage when typing">Autosave</span>',b+=" </div>",b+=" </li>",b+=" <li>",b+=' <div class="checkbox" onclick="settingsPanel.updateSetting(this);">',b+=' <div class="checkbox-inner"><input id="bda-css-2" type="checkbox" '+(customCssEditor.hideBackdrop?"checked":"")+"><span></span></div>",b+=' <span title="Hide the callout backdrop to disable modal close events">Hide Backdrop</span>',b+=" </div>",b+=" </li>",b+=" </ul>",b+=' <div id="bd-customcss-detach-controls-buttons">',b+=' <button class="btn btn-primary" id="bd-customcss-detached-update" onclick="return false;">Update</button>',b+=' <button class="btn btn-primary" id="bd-customcss-detached-save" onclick="return false;">Save</button>',b+=' <button class="btn btn-primary" id="bd-customcss-detached-detach" onclick="customCssEditor.detach(); return false;">Detach</button>',b+=" </div>",b+="</div>",this.attachEditor=b,$("#bd-customcss-innerpane").append(b),$("#bd-customcss-detached-update").on("click",function(){return a.applyCustomCss(a.editor.getValue(),!0,!1),!1}),$("#bd-customcss-detached-save").on("click",function(){return a.applyCustomCss(a.editor.getValue(),!1,!0),!1});var c="";c+='<div id="bd-customcss-detach-container">',c+=' <div id="bd-customcss-detach-editor">',c+=" </div>",c+="</div>",this.detachedEditor=c},CustomCssEditor.prototype.attach=function(){$("#editor-detached").hide(),$("#app-mount").removeClass("bd-detached-editor"),$("#bd-customcss-pane").append($("#bd-customcss-innerpane")),$("#bd-customcss-detached-detach").show(),$("#bd-customcss-detach-container").remove()},CustomCssEditor.prototype.detach=function(){this.attach(),$("#editor-detached").show(),$("#bd-customcss-detached-detach").hide(),$("#app-mount").addClass("bd-detached-editor"),$(".app").parent().append(this.detachedEditor),$("#bd-customcss-detach-editor").append($("#bd-customcss-innerpane"))},CustomCssEditor.prototype.applyCustomCss=function(a,b,c){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),(b||settingsCookie["bda-css-0"])&&$("#customcss").html(a),(c||settingsCookie["bda-css-1"])&&localStorage.setItem("bdcustomcss",btoa(a))};var settingsButton=null,panel=null;SettingsPanel.prototype.init=function(){var a=this;a.construct();var b=$("body");settingsCookie["bda-es-0"]?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide(),settingsCookie["bda-gs-2"]?b.addClass("bd-minimal"):b.removeClass("bd-minimal"),settingsCookie["bda-gs-3"]?b.addClass("bd-minimal-chan"):b.removeClass("bd-minimal-chan"),settingsCookie["bda-gs-4"]&&voiceMode.enable(),settingsCookie["bda-gs-5"]&&$("#app-mount").addClass("bda-dark"),settingsCookie["bda-es-6"]?(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 a=$(this).offset(),b=$(this).attr("alt");$(emoteNamePopup).find(".tipsy-inner").text(b),$(emoteNamePopup).css("left",a.left-25),$(emoteNamePopup).css("top",a.top-37),$(".app").append($(emoteNamePopup))}),$(document).on("mouseleave",".emote",function(){$(".tipsy").remove()})):$(document).off("mouseover",".emote"),settingsCookie["bda-gs-8"]?dMode.enable():dMode.disable()};var customCssInitialized=!1,lastTab="";SettingsPanel.prototype.changeTab=function(a){lastTab=a;$("#bd-control-groups");switch($(".bd-tab").removeClass("selected"),$(".bd-pane").hide(),$("#"+a).addClass("selected"),$("#"+a.replace("tab","pane")).show(),a){case"bd-settings-tab":$(".bda-slist-top").show();break;case"bd-emotes-tab":$(".bda-slist-top").show();break;case"bd-customcss-tab":$(".bda-slist-top").show(),customCssInitialized||(customCssEditor.init(),customCssInitialized=!0);break;case"bd-themes-tab":$(".bda-slist-top:first").hide();break;case"bd-plugins-tab":$(".bda-slist-top:first").hide();break;default:$(".bda-slist-top").show()}},SettingsPanel.prototype.updateSetting=function(a){var b=$(a).children().find('input[type="checkbox"]'),c=!b.is(":checked"),d=b.attr("id");b.prop("checked",c),"bda-css-2"==d&&($("#app-mount").removeClass("bd-hide-bd"),customCssEditor.hideBackdrop=c,c&&$("#app-mount").addClass("bd-hide-bd")),"bda-gs-8"==d&&c&&mainCore.alert("Developer Mode Enabled","Use F8 to break/resume execution<br>More coming soon"),settingsCookie[d]=c,this.updateSettings()},SettingsPanel.prototype.updateSettings=function(){settingsCookie["bda-es-0"]?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide(),settingsCookie["bda-gs-2"]?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal"),settingsCookie["bda-gs-3"]?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan"),settingsCookie["bda-gs-1"]?$("#bd-pub-li").show():$("#bd-pub-li").hide(),settingsCookie["bda-gs-4"]?voiceMode.enable():voiceMode.disable(),$("#app-mount").removeClass("bda-dark"),settingsCookie["bda-gs-5"]&&$("#app-mount").addClass("bda-dark"),settingsCookie["bda-es-6"]?(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 a=$(this).offset(),b=$(this).attr("alt");$(emoteNamePopup).find(".tipsy-inner").text(b),$(emoteNamePopup).css("left",a.left-25),$(emoteNamePopup).css("top",a.top-32),$("div[data-reactid='.0.1.1']").append($(emoteNamePopup))}),$(document).on("mouseleave",".emote",function(){$(".tipsy").remove()})):$(document).off("mouseover",".emote"),settingsCookie["bda-gs-8"]?dMode.enable():dMode.disable(),mainCore.saveSettings()},SettingsPanel.prototype.construct=function(){function a(){$(".tab-bar-item").removeClass("selected"),settingsButton.addClass("selected"),$(".form .settings-right .settings-inner").first().hide(),panel.show(),""==lastTab?b.changeTab("bd-settings-tab"):b.changeTab(lastTab)}var b=this;panel=$("<div/>",{id:"bd-pane",class:"settings-inner",css:{display:"none"}});var c=' <div class="scroller-wrap"> <div class="scroller settings-wrapper settings-panel"> <div class="tab-bar TOP"> <div class="tab-bar-item bd-tab" id="bd-settings-tab" onclick=\'settingsPanel.changeTab("bd-settings-tab");\'>Core </div> <div class="tab-bar-item bd-tab" id="bd-emotes-tab" onclick=\'settingsPanel.changeTab("bd-emotes-tab");\'>Emotes </div> <div class="tab-bar-item bd-tab" id="bd-customcss-tab" onclick=\'settingsPanel.changeTab("bd-customcss-tab");\'>Custom CSS </div> <div class="tab-bar-item bd-tab" id="bd-plugins-tab" onclick=\'settingsPanel.changeTab("bd-plugins-tab");\'>Plugins </div> <div class="tab-bar-item bd-tab" id="bd-themes-tab" onclick=\'settingsPanel.changeTab("bd-themes-tab");\'>Themes </div> <div class="bda-slist-top"> <button class="btn btn-primary" onclick="utils.exportSettings(); return false;">Export</button> <button class="btn btn-primary" onclick="utils.importSettings(); return false;">Import</button> </div> </div> <div class="bd-settings"> <div class="bd-pane control-group" id="bd-settings-pane" style="display:none;"> <ul class="checkbox-group"> ';for(var d in settings){var e=settings[d],f=e.id;"core"==e.cat&&e.implemented&&!e.hidden&&(c+=' <li> <div class="checkbox" onclick="settingsPanel.updateSetting(this);"> <div class="checkbox-inner"> <input type="checkbox" id="'+f+'" '+(settingsCookie[f]?"checked":"")+"> <span></span> </div> <span> "+d+" - "+e.info+" </span> </div> </li> ")}c+=" </ul> </div> ",c+=' <div class="bd-pane control-group" id="bd-emotes-pane" style="display:none;"> <ul class="checkbox-group"> ';for(var d in settings){var e=settings[d],f=e.id;"emote"==e.cat&&e.implemented&&!e.hidden&&(c+=' <li> <div class="checkbox" onclick="settingsPanel.updateSetting(this);"> <div class="checkbox-inner"> <input type="checkbox" id="'+f+'" '+(settingsCookie[f]?"checked":"")+"> <span></span> </div> <span> "+d+" - "+e.info+" </span> </div> </li> ")}c+=" </ul> </div> ";var g=atob(localStorage.getItem("bdcustomcss"));customCssEditor.applyCustomCss(g,!0,!1),c+=' <div class="bd-pane control-group" id="bd-customcss-pane" style="display:none;"> <div id="editor-detached" style="display:none;"> <h3>Editor Detached</h3> <button class="btn btn-primary" onclick="customCssEditor.attach(); return false;">Attach</button> </div> <div id="bd-customcss-innerpane"> <textarea id="bd-custom-css-ta">'+g+"</textarea> </div> </div> ",c+=' <div class="bd-pane control-group" id="bd-plugins-pane" style="display:show;"> <div class="bda-slist-top"> <button class="btn btn-primary" onclick=\'betterDiscordIPC.send("asynchronous-message", { "arg": "opendir", "path": "plugindir" }); return false;\'>Open Plugin Folder</button> <button class="btn btn-primary" onclick=\'window.open("https://betterdiscord.net/plugins"); return false;\'>Get Plugins</button> </div> <ul class="bda-slist"> ',$.each(bdplugins,function(){var a=this.plugin,b=!1;"function"==typeof a.getSettingsPanel&&(b=null!=a.getSettingsPanel()&&""!=a.getSettingsPanel()),c+=' <li> <div class="bda-left"> <span class="bda-name">'+a.getName()+" v"+a.getVersion()+" by "+a.getAuthor()+'</span> <div class="scroller-wrap fade"> <div class="scroller bda-description">'+a.getDescription()+'</div> </div> </div> <div class="bda-right"> <div class="checkbox" onclick="pluginModule.handlePlugin(this);"> <div class="checkbox-inner"> <input id="'+a.getName().replace(" ","__")+'" type="checkbox" '+(pluginCookie[a.getName()]?"checked":"")+'> <span></span> </div> <span></span> </div> <button class="btn btn-primary bda-plugin-reload" onclick="return false;" disabled>Reload</button> <button class="btn btn-primary bda-plugin-settings" onclick=\'pluginModule.showSettings("'+a.getName()+"\"); return false;' "+(b?"":"disabled")+">Settings</button> </div> </li> "}),c+=" </ul> </div> ",c+=' <div class="bd-pane control-group" id="bd-themes-pane" style="display:none;"> <div class="bda-slist-top"> <button class="btn btn-primary" onclick=\'betterDiscordIPC.send("asynchronous-message", { "arg": "opendir", "path": "themedir" }); return false;\'>Open Theme Folder</button> <button class="btn btn-primary" onclick=\'window.open("https://betterdiscord.net/themes"); return false;\'>Get Themes</button> </div> <ul class="bda-slist"> ',"undefined"==typeof themesupport2?c+="Your version does not support themes!":$.each(bdthemes,function(){c+=' <li> <div class="bda-left"> <span class="bda-name">'+this.name.replace(/_/g," ")+" v"+this.version+" by "+this.author+'</span> <div class="scroller-wrap fade"> <div class="scroller bda-description">'+this.description+'</div> </div> </div> <div class="bda-right"> <div class="checkbox" onclick="themeModule.handleTheme(this);"> <div class="checkbox-inner"> <input id="ti'+this.name+'" type="checkbox" '+(themeCookie[this.name]?"checked":"")+'> <span></span> </div> <span></span> </div> <button class="btn btn-primary bda-plugin-reload" onclick="return false;" disabled>Reload</button> </div> </li> '}),c+=" </ul> </div> ",c+=' <div style="background:#2E3136; color:#ADADAD; height:30px; position:absolute; bottom:0; left:0; right:0;"> <span style="line-height:30px;margin-left:10px;">BetterDiscord v'+("undefined"==typeof version?bdVersion:version)+"(JSv"+jsVersion+') by Jiiks</span> <span style="float:right;line-height:30px;margin-right:10px;"><a href="http://betterdiscord.net" target="_blank">BetterDiscord.net</a></span> <span id="bd-changelog" onclick=\'$("body").append(mainCore.constructChangelog());\'>changelog</span> </div> </div></div> ',settingsButton=$("<div/>",{class:"tab-bar-item",text:"BetterDiscord",id:"bd-settings-new",click:a}),panel.html(c),this.panel=panel},SettingsPanel.prototype.inject=function(a){if("childList"==a.type&&!(a.addedNodes.length<=0||$(a.addedNodes[0]).find(".user-settings-modal").length<=0)){var b=this;this.panel.hide();var c=$(".tab-bar.SIDE").first();$(".tab-bar.SIDE .tab-bar-item").click(function(){$(".form .settings-right .settings-inner").first().show(),$("#bd-settings-new").removeClass("selected"),b.panel.hide()}),c.append(settingsButton),$(".form .settings-right .settings-inner").last().after(b.panel),$("#bd-settings-new").removeClass("selected")}};var _hash;Utils.prototype.getTextArea=function(){return $(".channel-textarea-inner textarea")},Utils.prototype.jqDefer=function(a){window.jQuery?a():setTimeout(function(){this.jqDefer(a)},100)},Utils.prototype.getHash=function(){$.getJSON("https://api.github.com/repos/Jiiks/BetterDiscordApp/commits/master",function(a){_hash=a.sha,emoteModule.getBlacklist()})},Utils.prototype.loadHtml=function(a,b){var c=$("<div/>",{class:"bd-container"}).appendTo("body");a="//cdn.rawgit.com/Jiiks/BetterDiscordApp/"+_hash+"/html/"+a+".html",c.load(a,b())},Utils.prototype.injectJs=function(a){$("<script/>",{type:"text/javascript",src:a}).appendTo($("body"))},Utils.prototype.injectCss=function(a){$("<link/>",{type:"text/css",rel:"stylesheet",href:a}).appendTo($("head"))},Utils.prototype.log=function(a){console.log("%c[%cBetterDiscord%c] %c"+a,"color: red;","color: #303030; font-weight:700;","color:red;","")},Utils.prototype.err=function(a){console.log("%c[%cBetterDiscord%c] %c"+a,"color: red;","color: red; font-weight:700;","color:red;","")},Utils.prototype.importSettings=function(){mainCore.alert("Import Settings",'<div class="form" style="width:100%;"><div class="control-group"><textarea id="bda-import-textarea" style="min-height:150px;"></textarea></div><button id="bda-import-settings" class="btn btn-primary">Import</button></div>'),$("#bda-import-settings").off("click").on("click",function(){var a;try{a=JSON.parse($("#bda-import-textarea").val())}catch(a){return mainCore.alert("Invalid Data",a),!1}try{for(key in a.settings){var b=a.settings[key];if(settingsCookie.hasOwnProperty(key)){settingsCookie[key]=b;var c=$("#"+key);c.prop("checked",b),settingsPanel.updateSettings()}}localStorage.bdcustomcss=a.customCss;var d=atob(localStorage.getItem("bdcustomcss"));customCssInitialized||(customCssEditor.init(),customCssInitialized=!0),customCssEditor.applyCustomCss(d,settingsCookie["bda-css-0"],!1),customCssEditor.editor.setValue(d)}catch(a){return mainCore.alert("Invalid Data",a),!1}try{$.each(a.plugins,function(b){var c=a.plugins[b];if(bdplugins.hasOwnProperty(b)){pluginCookie[b]=c;var d=$("#"+b.replace(" ","__"));d.is(":checked")&&!c&&(bdplugins[b].plugin.stop(),d.prop("checked",!1)),!d.is(":checked")&&c&&(bdplugins[b].plugin.start(),d.prop("checked",!0))}}),pluginModule.savePluginData()}catch(a){return mainCore.alert("Failed to load plugin data",a),!1}try{themeCookie=a.themes,$.each(themeCookie,function(a){var b=themeCookie[a],c="#ti"+a;bdthemes.hasOwnProperty(a)&&($(c).is(":checked")&&!b&&($(c).prop("checked",!1),$("#"+a).remove()),!$(c).is(":checked")&&b&&($(c).prop("checked",!0),$("head").append('<style id="'+a+'">'+unescape(bdthemes[a].css)+"</style>")))}),themeModule.saveThemeData()}catch(a){return mainCore.alert("Failed to load theme data",a),!1}return!1})},Utils.prototype.exportSettings=function(){var a={settings:settingsCookie,customCss:localStorage.bdcustomcss,plugins:pluginCookie,themes:themeCookie,favEmotes:window.localStorage.bdfavemotes};mainCore.alert("Export Settings",'<div class="form" style="width:100%;"><div class="control-group"><textarea style="min-height:150px;">'+JSON.stringify(a)+"</textarea></div></div>")},Utils.prototype.addBackdrop=function(a){var b=$("<div/>",{class:"bda-backdrop","data-bdbackdrop":a,mouseup:function(){$('[data-bdalert="'+a+'"]').remove(),$(this).remove()}});$("#app-mount").append(b)},Utils.prototype.removeBackdrop=function(a){$('[data-bdbackdrop="'+a+'"]').remove()},VoiceMode.prototype.obsCallback=function(){var a=this;settingsCookie["bda-gs-4"]&&(a.disable(),setTimeout(function(){a.enable()},300))},VoiceMode.prototype.enable=function(){$(".scroller.guild-channels ul").first().css("display","none"),$(".scroller.guild-channels header").first().css("display","none"),$(".app.flex-vertical").first().css("overflow","hidden"),$(".chat.flex-vertical.flex-spacer").first().css("visibility","hidden").css("min-width","0px"),$(".flex-vertical.channels-wrap").first().css("flex-grow","100000"),$(".guild-header .btn.btn-hamburger").first().css("visibility","hidden")},VoiceMode.prototype.disable=function(){$(".scroller.guild-channels ul").first().css("display",""),$(".scroller.guild-channels header").first().css("display",""),$(".app.flex-vertical").first().css("overflow",""),$(".chat.flex-vertical.flex-spacer").first().css("visibility","").css("min-width",""),$(".flex-vertical.channels-wrap").first().css("flex-grow",""),$(".guild-header .btn.btn-hamburger").first().css("visibility","")};var pluginCookie={};PluginModule.prototype.loadPlugins=function(){this.loadPluginData(),$.each(bdplugins,function(){var a=this.plugin;a.load();var b=a.getName(),c=!1;pluginCookie.hasOwnProperty(b)?c=pluginCookie[b]:pluginCookie[b]=!1,c&&a.start()})},PluginModule.prototype.handlePlugin=function(a){var b=$(a).children().find('input[type="checkbox"]'),c=!b.is(":checked"),d=b.attr("id").replace("__"," ");b.prop("checked",c),c?(bdplugins[d].plugin.start(),pluginCookie[d]=!0):(bdplugins[d].plugin.stop(),pluginCookie[d]=!1),this.savePluginData()},PluginModule.prototype.showSettings=function(a){if(null!=bdplugins[a]&&"function"==typeof bdplugins[a].plugin.getSettingsPanel){var b=bdplugins[a].plugin.getSettingsPanel();$(".modal-inner").off("click.bdpsm").on("click.bdpsm",function(a){$("#bd-psm-id").length?$(".bd-psm").remove():$(".bd-psm").attr("id","bd-psm-id")}),$(".modal").append('<div class="bd-psm"><div class="scroller-wrap" style="height:100%"><div id="bd-psm-s" class="scroller" style="padding:10px;"></div></div></div>'),$("#bd-psm-s").append(b)}},PluginModule.prototype.loadPluginData=function(){var a=$.cookie("bd-plugins");void 0!=a&&(pluginCookie=JSON.parse($.cookie("bd-plugins")))},PluginModule.prototype.savePluginData=function(){$.cookie("bd-plugins",JSON.stringify(pluginCookie),{expires:365,path:"/"})},PluginModule.prototype.newMessage=function(){$.each(bdplugins,function(){pluginCookie[this.plugin.getName()]&&"function"==typeof this.plugin.onMessage&&this.plugin.onMessage()})},PluginModule.prototype.channelSwitch=function(){$.each(bdplugins,function(){pluginCookie[this.plugin.getName()]&&"function"==typeof this.plugin.onSwitch&&this.plugin.onSwitch()})},PluginModule.prototype.socketEvent=function(a,b){$.each(bdplugins,function(){pluginCookie[this.plugin.getName()]&&"function"==typeof this.plugin.socketEvent&&this.plugin.socketEvent(b)})},PluginModule.prototype.rawObserver=function(a){$.each(bdplugins,function(){pluginCookie[this.plugin.getName()]&&"function"==typeof this.plugin.observer&&this.plugin.observer(a)})};var themeCookie={};ThemeModule.prototype.loadThemes=function(){this.loadThemeData(),$.each(bdthemes,function(){var a=this.name,b=!1;themeCookie.hasOwnProperty(a)?themeCookie[a]&&(b=!0):themeCookie[a]=!1,b&&$("head").append('<style id="'+a+'">'+unescape(bdthemes[a].css)+"</style>")})},ThemeModule.prototype.handleTheme=function(a){var b=$(a).children().find('input[type="checkbox"]'),c=!b.is(":checked"),d=b.attr("id").substring(2);b.prop("checked",c),c?($("head").append('<style id="'+d+'">'+unescape(bdthemes[d].css)+"</style>"),themeCookie[d]=!0):($("#"+d).remove(),themeCookie[d]=!1),this.saveThemeData()},ThemeModule.prototype.loadThemeData=function(){var a=$.cookie("bd-themes");void 0!=a&&(themeCookie=JSON.parse($.cookie("bd-themes")))},ThemeModule.prototype.saveThemeData=function(){$.cookie("bd-themes",JSON.stringify(themeCookie),{expires:365,path:"/"})};var bdSocket,bdws;BdWSocket.prototype.start=function(){},BdWSocket.prototype.open=function(a){utils.log("Socket Host: "+a);try{bdSocket=new WebSocket(a),bdSocket.onopen=this.onOpen,bdSocket.onmessage=this.onMessage,bdSocket.onerror=this.onError,bdSocket.onclose=this.onClose}catch(a){utils.log(a)}},BdWSocket.prototype.onOpen=function(){utils.log("Socket Open");var a={op:2,d:{token:JSON.parse(localStorage.getItem("token")),properties:JSON.parse(localStorage.getItem("superProperties")),v:3}};bdws.send(a)},BdWSocket.prototype.onMessage=function(a){var b,c,d;try{b=JSON.parse(a.data),c=b.d,d=b.t}catch(a){return void utils.err(a)}switch(d){case"READY":bdSocket.interval=setInterval(function(){bdws.send({op:1,d:Date.now()})},c.heartbeat_interval),utils.log("Socket Ready");break;case"PRESENCE_UPDATE":pluginModule.socketEvent("PRESENCE_UPDATE",c);break;case"TYPING_START":pluginModule.socketEvent("TYPING_START",c);break;case"MESSAGE_CREATE":pluginModule.socketEvent("MESSAGE_CREATE",c);break;case"MESSAGE_UPDATE":pluginModule.socketEvent("MESSAGE_UPDATE",c)}},BdWSocket.prototype.onError=function(a){utils.log("Socket Error - "+a.message)},BdWSocket.prototype.onClose=function(a){utils.log("Socket Closed - "+a.code+" : "+a.reason),clearInterval(bdSocket.interval),bdws.start()},BdWSocket.prototype.send=function(a){1==bdSocket.readyState&&bdSocket.send(JSON.stringify(a))},BdWSocket.prototype.getSocket=function(){return bdSocket},BdApi.joinServer=function(a){opublicServers.joinServer(a)},BdApi.injectCSS=function(a,b){$("head").append('<style id="'+a+'"></style>'),$("#"+a).html(b)},BdApi.clearCSS=function(a){$("#"+a).remove()},BdApi.getPlugin=function(a){return bdplugins.hasOwnProperty(a)?bdplugins[a].plugin:null},BdApi.getIpc=function(){return betterDiscordIPC},BdApi.getCore=function(){return mainCore},BdApi.getUserIdByName=function(a){for(var b=$(".member-username"),c=0;c<b.length;c++){var d=$(b[c]);if(d.text()==a){var e=d.closest(".member").find(".avatar-small").css("background-image");return e.match(/\d+/)}}return null};var gg;BdApi.getUserNameById=function(a){for(var b=$(".avatar-small"),c=0;c<b.length;c++){var d=$(b[c]),e=d.css("background-image");if(a==e.match(/\d+/))return d.parent().find(".member-username").text()}return null},BdApi.setPlaying=function(a){bdws.send({op:3,d:{idle_since:null,game:{name:a}}})},BdApi.setStatus=function(a,b){bdws.send({op:3,d:{idle_since:a,game:{name:b}}})},devMode.prototype.enable=function(){$(window).on("keydown.bdDevmode",function(a){119===a.which})},devMode.prototype.disable=function(){$(window).off("keydown.bdDevmode"),$(window).off("mousedown.bdDevmode")};