BetterDiscordApp-v1/js/main.min.js

2 lines
42 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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(){}var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule,customCssEditor,jsVersion=1.63,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"},"Show Emotes":{id:"bda-es-7",info:"Show any 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:"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"}},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-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:{darkmode:{title:"v1.63 : Dark Mode",text:"Dark mode makes certain elements dark by default(currently only applies to emote menu)",img:""},emotemenu:{title:"v1.62 : Brand new emote menu that fits in Discord emoji menu!",text:"The emote menu has been replaced by a new one that injects itself in the Discord emoji menu!",img:""},cccss:{title:"v1.61 : New custom CSS editor",text:"The custom CSS editor now has options and can be detached!",img:""},vdc:{title:"v1.61 : Voice Disconnect",text:"Disconnect from voice server when closing Discord!",img:""},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:{modal:{title:"v1.62 : Fixed modals",text:"Fixed broken modal introduced by 0.0.287",imt:""},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:""}}},settingsCookie={};Core.prototype.init=function(){function e(){if(console.log((new Date).getTime()+" Defer"),$(".guilds-wrapper .guilds").children().length>0){console.log((new Date).getTime()+" Defer Loaded");var i=($(".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"),t.saveSettings()}}));if($(".guilds-wrapper").prepend(i),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()}),opublicServers.init(),emoteModule.autoCapitalize(),settingsCookie.version<jsVersion){var s=t.constructChangelog();$("body").append(s),settingsCookie.version=jsVersion,t.saveSettings()}$("head").append("<style>.CodeMirror{ min-width:100%; }</style>"),$("head").append('<style id="bdemotemenustyle"></style>')}else setTimeout(e,100)}var t=this;if(version<supportedVersion)return void 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>");utils=new Utils;var i=new BdWSocket;i.start(),utils.getHash(),emoteModule=new EmoteModule,quickEmoteMenu=new QuickEmoteMenu,voiceMode=new VoiceMode,emoteModule.init(),this.initSettings(),this.initObserver(),$(document).ready(function(){setTimeout(e,1e3)})},Core.prototype.initSettings=function(){if(void 0==$.cookie("better-discord"))settingsCookie=defaultCookie,this.saveSettings();else{this.loadSettings();for(var e in defaultCookie)void 0==settingsCookie[e]&&(settingsCookie[e]=defaultCookie[e],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(e){e.forEach(function(e){if($(e.target).find(".emoji-picker").length){var t=e.target.firstChild;t.classList.contains("popout")&&quickEmoteMenu.obsCallback($(t))}"undefined"!=typeof pluginModule&&pluginModule.rawObserver(e),null!=e.target.getAttribute("class")&&((e.target.classList.contains("title-wrap")||e.target.classList.contains("chat"))&&(voiceMode.obsCallback(),"undefined"!=typeof pluginModule&&pluginModule.channelSwitch()),-1!=e.target.getAttribute("class").indexOf("scroller messages")&&"undefined"!=typeof pluginModule&&pluginModule.newMessage()),emoteModule.obsCallback(e)})}),mainObserver.observe(document,{childList:!0,subtree:!0})},Core.prototype.constructChangelog=function(){var e='<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){e+='<h1 class="changelog-added"> <span>New Stuff</span></h1><ul>';for(var t in bdchangelog.changes)t=bdchangelog.changes[t],e+="<li> <strong>"+t.title+"</strong> <div>"+t.text+"</div></li>";e+="</ul>"}if(null!=bdchangelog.fixes){e+='<h1 class="changelog-fixed"> <span>Fixed</span></h1><ul>';for(var i in bdchangelog.fixes)i=bdchangelog.fixes[i],e+="<li> <strong>"+i.title+"</strong> <div>"+i.text+"</div></li>";e+="</ul>"}if(null!=bdchangelog.upcoming){e+='<h1 class="changelog-in-progress"> <span>Coming Soon</span></h1><ul>';for(var s in bdchangelog.upcoming)s=bdchangelog.upcoming[s],e+="<li> <strong>"+s.title+"</strong> <div>"+s.text+"</div></li>";e+="</ul>"}return e+=' </div><!--scoller--> </div><!--scroller-wrap--> <div class="footer"> </div><!--footer--> </div><!--change-log--> </div><!--modal-inner--></div><!--modal-->'},Core.prototype.alert=function(e,t){$("body").append('<div class="bd-alert"> <div class="bd-alert-header"> <span>'+e+'</span> <div class="bd-alert-closebtn" onclick="$(this).parent().parent().remove();">×</div> </div> <div class="bd-alert-body"> <div class="scroller-wrap dark fade"> <div class="scroller">'+t+"</div> </div> </div></div>")};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(e){bemotes=e.blacklist})},EmoteModule.prototype.obsCallback=function(e){var t=this;if(settingsCookie["bda-es-7"]){$(".emoji").each(function(){var e=$(this);if(-1!=e.attr("src").indexOf(".png")){var t=e.next(),i=e.attr("alt");t.size()>0&&"SPAN"==t.prop("tagName")&&(i+=t.text(),t.remove()),"SPAN"!=e.parent().prop("tagName")?e.replaceWith("<span>"+i+"</span>"):e.replaceWith(i)}});for(var i=0;i<e.addedNodes.length;++i){var s=e.addedNodes.item(i);if(s){var o=t.getNodes(s);for(var n in o)o.hasOwnProperty(n)&&t.injectEmote(o[n])}}}},EmoteModule.prototype.getNodes=function(e){for(var t,i=[],s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1);t=s.nextNode();)i.push(t);return i};var bemotes=[],spoilered=[];EmoteModule.prototype.injectEmote=function(e){function t(){var e=i.innerHTML,t=e.split(/\s+/g);if(t&&(t.some(function(t){if("[!s]"==t.slice(0,4)){e=e.replace("[!s]","");var s=$(i).parent(),o=s.attr("data-reactid");if(spoilered.indexOf(o)>-1)return;return s.addClass("spoiler"),void s.on("click",function(){$(this).removeClass("spoiler"),spoilered.push($(this).attr("data-reactid"))})}if(!(t.length<4)){if("ClauZ"==t)return void(e=e.replace("ClauZ",'<img src="https://cdn.frankerfacez.com/emoticon/70852/1" style="width:25px; transform:translate(-29px, -14px);"></img>'));var n=!1,a=t,d="",r=["emoteflip","emotespin","emotepulse","emotespin2","emotespin3","emote1spin","emote2spin","emote3spin","emotetr","emotebl","emotebr","emoteshake","emoteshake2","emoteshake3","emoteflap"];if(t.indexOf(":")>-1){var c=t.split(/:(?!.*:)/);""!=c[0]&&""!=c[1]&&(userEmoteCss=!0,a=c[0],"bttv"==c[1]&&(n=!0),settingsCookie["bda-es-8"]&&(d="emote"+c[1],r.indexOf(d)<0&&(d="")))}if(-1==$.inArray(a,bemotes)){if(emotesTwitch.emotes.hasOwnProperty(a)){var l=Math.round(a.length/4),p=a.substr(0,l)+"﷙"+a.substr(l,l)+"﷙"+a.substr(2*l,l)+"﷙"+a.substr(3*l),u=twitchEmoteUrlStart+emotesTwitch.emotes[a].image_id+twitchEmoteUrlEnd;return void(e=e.replace(t,'<div class="emotewrapper"><img class="emote '+d+'" alt="'+p+'" src="'+u+'"/><input onclick=\'quickEmoteMenu.favorite("'+p+'", "'+u+'");\' class="fav" title="Favorite!" type="button"></div>'))}if(subEmotesTwitch.hasOwnProperty(a)){var l=Math.round(a.length/4),p=a.substr(0,l)+"﷙"+a.substr(l,l)+"﷙"+a.substr(2*l,l)+"﷙"+a.substr(3*l),u=twitchEmoteUrlStart+subEmotesTwitch[a]+twitchEmoteUrlEnd;return void(e=e.replace(t,'<div class="emotewrapper"><img class="emote '+d+'" alt="'+p+'" src="'+u+'"/><input onclick=\'quickEmoteMenu.favorite("'+p+'", "'+u+'");\' class="fav" title="Favorite!" type="button"></div>'))}if("undefined"!=typeof emotesBTTV&&settingsCookie["bda-es-2"]&&emotesBTTV.hasOwnProperty(a)){var l=Math.round(a.length/4),p=a.substr(0,l)+"﷙"+a.substr(l,l)+"﷙"+a.substr(2*l,l)+"﷙"+a.substr(3*l),u=emotesBTTV[a];return void(e=e.replace(t,'<div class="emotewrapper"><img class="emote '+d+'" alt="'+p+'" src="'+u+'"/><input onclick=\'quickEmoteMenu.favorite("'+p+'", "'+u+'");\' class="fav" title="Favorite!" type="button"></div>'))}if("undefined"!=typeof emotesFfz&&settingsCookie["bda-es-1"]&&(!n||!emotesBTTV2.hasOwnProperty(a))&&emotesFfz.hasOwnProperty(a)){var l=Math.round(a.length/4),p=a.substr(0,l)+"﷙"+a.substr(l,l)+"﷙"+a.substr(2*l,l)+"﷙"+a.substr(3*l),u=ffzEmoteUrlStart+emotesFfz[a]+ffzEmoteUrlEnd;return void(e=e.replace(t,'<div class="emotewrapper"><img class="emote '+d+'" alt="'+p+'" src="'+u+'"/><input onclick=\'quickEmoteMenu.favorite("'+p+'", "'+u+'");\' class="fav" title="Favorite!" type="button"></div>'))}if("undefined"!=typeof emotesBTTV2&&settingsCookie["bda-es-2"]&&emotesBTTV2.hasOwnProperty(a)){var l=Math.round(a.length/4),p=a.substr(0,l)+"﷙"+a.substr(l,l)+"﷙"+a.substr(2*l,l)+"﷙"+a.substr(3*l);n&&(p=t.substr(0,l)+"﷙"+t.substr(l,l)+"﷙"+t.substr(2*l,l)+"﷙"+t.substr(3*l));var u=bttvEmoteUrlStart+emotesBTTV2[a]+bttvEmoteUrlEnd;return void(e=e.replace(t,'<div class="emotewrapper"><img class="emote '+d+'" alt="'+p+'" src="'+u+'"/><input onclick=\'quickEmoteMenu.favorite("'+p+'", "'+u+'");\' class="fav" title="Favorite!" type="button"></div>'))}}}}),null!=i.parentElement)){var s=i.parentElement.offsetHeight;i.innerHTML=e.replace(new RegExp("﷙","g"),"");var o=i.parentElement.offsetHeight,n=$(".scroller.messages").first();n.scrollTop(n.scrollTop()+(o-s))}}if("undefined"!=typeof emotesTwitch&&e.parentElement){var i=e.parentElement;if("SPAN"==i.tagName&&($(i.parentElement).hasClass("markup")||$(i.parentElement).hasClass("message-content"))){var s=!1;$(i.parentElement).hasClass("edited")&&(i=i.parentElement.parentElement.firstChild,s=!0),s?setTimeout(t,250):t()}}},EmoteModule.prototype.autoCapitalize=function(){var e=this;$("body").delegate($(".channel-textarea-inner textarea"),"keyup change paste",function(){if(settingsCookie["bda-es-4"]){var t=$(".channel-textarea-inner textarea").val();if(void 0!=t){var i=t.split(" ").pop();if(i.length>3){if("danSgame"==i)return;var s=e.capitalize(i.toLowerCase());null!==s&&void 0!==s&&$(".channel-textarea-inner textarea").val(t.replace(i,s))}}}})},EmoteModule.prototype.capitalize=function(e){var t=emotesTwitch.emotes;for(var i in t)if(t.hasOwnProperty(i)&&e==(i+"").toLowerCase())return i},PublicServers.prototype.getPanel=function(){return this.container},PublicServers.prototype.init=function(){var e=this,t=$(".guilds>li:first-child");t.after($("<li></li>",{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(){e.show()});var i="";i+='<div id="pubs-container">',i+=' <div id="pubs-spinner">',i+=' <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>',i+=" </div>",i+=' <div id="pubs-header">',i+=' <h2 id="pubs-header-title">Public Servers</h2>',i+=' <button id="sbtn">Search</button>',i+=' <input id="sterm" type="text" placeholder="Search term..."/>',i+=" </div>",i+=' <div class="scroller-wrap">',i+=' <div class="scroller">',i+=' <div id="slist" class="servers-listing">',i+=" ",i+=" </div>",i+=" </div>",i+=" </div>",i+=' <div id="pubs-footer">',i+=' <div>Server list provided by <a href="https://www.discordservers.com/" target="_blank">DiscordServers.com</a></div>',i+=" </div>",i+="</div>",this.container=i,$("#bd-pub-li").length<1&&setTimeout(function(){e.init()},250)},PublicServers.prototype.show=function(){var e=this;$("body").append(this.getPanel());var t={sort:[{online:"desc"}],from:0,size:20,query:{filtered:{query:{match_all:{}}}}};$("#sbtn").on("click",function(){e.search()}),$("#sterm").on("keyup",function(t){13==t.keyCode&&e.search()}),this.loadServers(t,!1);var e=this;$(document).on("mouseup.bdps",function(t){$("#bd-pub-button").is(t.target)||$("#pubs-container").is(t.target)||0!==$("#pubs-container").has(t.target).length||e.hide()})},PublicServers.prototype.hide=function(){$("#pubs-container").remove(),$(document).off("mouseup.bdps")},PublicServers.prototype.loadServers=function(e,t){var i=this;$("#sbtn").prop("disabled",!0),$("#sterm").prop("disabled",!0),$("#slist").empty(),$("#pubs-spinner").show(),$.ajax({type:"POST",dataType:"json",url:"https://search-discordservers-izrtub5nprzrl76ugyy6hdooe4.us-west-1.es.amazonaws.com/app/_search",crossDomain:!0,data:JSON.stringify(e),success:function(e){var s=e.hits.hits;t?$("#pubs-header-title").text("Public Servers - Search Results: "+s.length):$("#pubs-header-title").text("Public Servers"),s.forEach(function(e){var t=e._source,s=t.invite_code,o='<div class="server-row">';o+='<div class="server-icon" style="background-image:url('+t.icon+')"></div>',o+='<div class="server-info server-name">',o+="<span>"+t.name+" by "+t.owner.name+"</span>",o+="</div>",o+='<div class="server-info server-members">',o+="<span>"+t.online+"/"+t.members+" Members</span>",o+="</div>",o+='<div class="server-info server-region">',o+="<span>"+t.region+"</span>",o+="</div>",o+='<div class="server-info">',o+="<button data-server-invite-code="+s+">Join</button>",o+="</div>",o+="</div>",$("#slist").append(o),$("button[data-server-invite-code="+s+"]").on("click",function(){i.joinServer(s)})})},done:function(){$("#pubs-spinner").hide(),$("#sbtn").prop("disabled",!1),$("#sterm").prop("disabled",!1)},always:function(){$("#pubs-spinner").hide(),$("#sbtn").prop("disabled",!1),$("#sterm").prop("disabled",!1)},error:function(){$("#pubs-spinner").hide(),$("#sbtn").prop("disabled",!1),$("#sterm").prop("disabled",!1)},complete:function(){$("#pubs-spinner").hide(),$("#sbtn").prop("disabled",!1),$("#sterm").prop("disabled",!1)}})},PublicServers.prototype.search=function(){var e={sort:[{online:"desc"}],from:0,size:20,query:{filtered:{query:{match_all:{}}}}},t={filter:{and:[{query:{match_phrase_prefix:{name:$("#sterm").val()}}}]}};$("#sterm").val()&&$.extend(e,t),this.loadServers(e,!0)},PublicServers.prototype.joinServer=function(e){$(".guilds-add").click(),$(".action.join .btn").click(),$(".create-guild-container input").val(e),$(".form.join-server .btn-primary").click()},QuickEmoteMenu.prototype.init=function(){$(document).on("mousedown",function(e){"rmenu"!=e.target.id&&$("#rmenu").remove()}),this.favoriteEmotes={};var e=localStorage.bdfavemotes;void 0!=e&&(this.favoriteEmotes=JSON.parse(atob(e)));var t="";t+='<div id="bda-qem">',t+=' <button class="active" id="bda-qem-twitch" onclick=\'quickEmoteMenu.switchHandler(this); return false;\'>Twitch</button>',t+=" <button id=\"bda-qem-favourite\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Favourite</button>",t+=" <button id=\"bda-qem-emojis\" onclick='quickEmoteMenu.switchHandler(this); return false;'>Emojis</buttond>",t+="</div>",this.qmeHeader=t;var i="";i+='<div id="bda-qem-twitch-container">',i+=' <div class="scroller-wrap fade">',i+=' <div class="scroller">',i+=' <div class="emote-menu-inner">';for(var s in emotesTwitch.emotes)if(emotesTwitch.emotes.hasOwnProperty(s)){var o=emotesTwitch.emotes[s].image_id;i+='<div class="emote-container">',i+=' <img class="emote-icon" id="'+s+'" alt="" src="https://static-cdn.jtvnw.net/emoticons/v1/'+o+'/1.0" title="'+s+'">',i+=" </img>",i+="</div>"}i+=" </div>",i+=" </div>",i+=" </div>",i+="</div>",this.teContainer=i;var n="";n+='<div id="bda-qem-favourite-container">',n+=' <div class="scroller-wrap fade">',n+=' <div class="scroller">',n+=' <div class="emote-menu-inner">';for(var s in this.favoriteEmotes){var a=this.favoriteEmotes[s];n+='<div class="emote-container">',n+=' <img class="emote-icon" alt="" src="'+a+'" title="'+s+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",n+=" </img>",n+="</div>"}n+=" </div>",n+=" </div>",n+=" </div>",n+="</div>",this.faContainer=n},QuickEmoteMenu.prototype.favContext=function(e,t){e.stopPropagation();var i=$("<div/>",{id:"rmenu","data-emoteid":$(t).prop("title"),text:"Remove"});return i.css({top:e.pageY-$("#bda-qem-favourite-container").offset().top,left:e.pageX-$("#bda-qem-favourite-container").offset().left}),$(t).parent().append(i),i.on("click",function(e){return e.preventDefault(),e.stopPropagation(),$(this).remove(),console.log($(this).data("emoteid")),delete quickEmoteMenu.favoriteEmotes[$(this).data("emoteid")],quickEmoteMenu.updateFavorites(),!1}),!1},QuickEmoteMenu.prototype.switchHandler=function(e){this.switchQem($(e).attr("id"))},QuickEmoteMenu.prototype.switchQem=function(e){var t=$("#bda-qem-twitch"),i=$("#bda-qem-favourite"),s=$("#bda-qem-emojis");switch(t.removeClass("active"),i.removeClass("active"),s.removeClass("active"),$(".emoji-picker").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),e){case"bda-qem-twitch":t.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":i.addClass("active"),$("#bda-qem-favourite-container").show();break;case"bda-qem-emojis":s.addClass("active"),$(".emoji-picker").show()}this.lastTab=e;var o=$(".emote-icon");o.off(),o.on("click",function(){var e=$(this).attr("title"),t=$(".channel-textarea-inner textarea");t.val(" "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)})},QuickEmoteMenu.prototype.obsCallback=function(e){if(settingsCookie["bda-es-9"]?e.removeClass("bda-qme-hidden"):e.addClass("bda-qme-hidden"),settingsCookie["bda-es-0"]){e.prepend(this.qmeHeader),e.append(this.teContainer),e.append(this.faContainer),void 0==this.lastTab&&(this.lastTab="bda-qem-favourite"),this.switchQem(this.lastTab)}},QuickEmoteMenu.prototype.favorite=function(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()},QuickEmoteMenu.prototype.updateFavorites=function(){var e="";e+='<div id="bda-qem-favourite-container">',e+=' <div class="scroller-wrap fade">',e+=' <div class="scroller">',e+=' <div class="emote-menu-inner">';for(var t in this.favoriteEmotes){var i=this.favoriteEmotes[t];e+='<div class="emote-container">',e+=' <img class="emote-icon" alt="" src="'+i+'" title="'+t+"\" oncontextmenu='quickEmoteMenu.favContext(event, this);'>",e+=" </img>",e+="</div>"}e+=" </div>",e+=" </div>",e+=" </div>",e+="</div>",this.faContainer=e,$("#bda-qem-favourite-container").replaceWith(e),window.localStorage.bdfavemotes=btoa(JSON.stringify(this.favoriteEmotes))},CustomCssEditor.prototype.init=function(){var e=this;e.hideBackdrop=!1,e.editor=CodeMirror.fromTextArea(document.getElementById("bd-custom-css-ta"),{lineNumbers:!0,mode:"css",indentUnit:4,theme:"neat"}),e.editor.on("change",function(t){var i=t.getValue();e.applyCustomCss(i,!1,!1)});var t="";t+='<div id="bd-customcss-attach-controls">',t+=' <ul class="checkbox-group">',t+=" <li>",t+=' <div class="checkbox" onclick="settingsPanel.updateSetting(this);">',t+=' <div class="checkbox-inner"><input id="bda-css-0" type="checkbox" '+(settingsCookie["bda-css-0"]?"checked":"")+"><span></span></div>",t+=' <span title="Update client css while typing">Live Update</span>',t+=" </div>",t+=" </li>",t+=" <li>",t+=' <div class="checkbox" onclick="settingsPanel.updateSetting(this);">',t+=' <div class="checkbox-inner"><input id="bda-css-1" type="checkbox" '+(settingsCookie["bda-css-1"]?"checked":"")+"><span></span></div>",t+=' <span title="Autosave css to localstorage when typing">Autosave</span>',t+=" </div>",t+=" </li>",t+=" <li>",t+=' <div class="checkbox" onclick="settingsPanel.updateSetting(this);">',t+=' <div class="checkbox-inner"><input id="bda-css-2" type="checkbox" '+(customCssEditor.hideBackdrop?"checked":"")+"><span></span></div>",t+=' <span title="Hide the callout backdrop to disable modal close events">Hide Backdrop</span>',t+=" </div>",t+=" </li>",t+=" </ul>",t+=' <div id="bd-customcss-detach-controls-buttons">',t+=' <button class="btn btn-primary" id="bd-customcss-detached-update" onclick="return false;">Update</button>',t+=' <button class="btn btn-primary" id="bd-customcss-detached-save" onclick="return false;">Save</button>',t+=' <button class="btn btn-primary" id="bd-customcss-detached-detach" onclick="customCssEditor.detach(); return false;">Detach</button>',t+=" </div>",t+="</div>",this.attachEditor=t,$("#bd-customcss-innerpane").append(t),$("#bd-customcss-detached-update").on("click",function(){return e.applyCustomCss(e.editor.getValue(),!0,!1),!1}),$("#bd-customcss-detached-save").on("click",function(){return e.applyCustomCss(e.editor.getValue(),!1,!0),!1});var i="";i+='<div id="bd-customcss-detach-container">',i+=' <div id="bd-customcss-detach-editor">',i+=" </div>",i+="</div>",this.detachedEditor=i},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(e,t,i){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),(t||settingsCookie["bda-css-0"])&&$("#customcss").html(e),(i||settingsCookie["bda-css-1"])&&localStorage.setItem("bdcustomcss",btoa(e))};var settingsButton=null,panel=null;SettingsPanel.prototype.init=function(){var e=this;e.construct();var t=$("body");settingsCookie["bda-es-0"]?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide(),settingsCookie["bda-gs-2"]?t.addClass("bd-minimal"):t.removeClass("bd-minimal"),settingsCookie["bda-gs-3"]?t.addClass("bd-minimal-chan"):t.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 e=$(this).offset(),t=$(this).attr("alt");$(emoteNamePopup).find(".tipsy-inner").text(t),$(emoteNamePopup).css("left",e.left-25),$(emoteNamePopup).css("top",e.top-32),$("div[data-reactid='.0.1.1']").append($(emoteNamePopup))}),$(document).on("mouseleave",".emote",function(){$(".tipsy").remove()})):$(document).off("mouseover",".emote")};var customCssInitialized=!1,lastTab="";SettingsPanel.prototype.changeTab=function(e){lastTab=e;$("#bd-control-groups");switch($(".bd-tab").removeClass("selected"),$(".bd-pane").hide(),$("#"+e).addClass("selected"),$("#"+e.replace("tab","pane")).show(),e){case"bd-settings-tab":break;case"bd-customcss-tab":customCssInitialized||(customCssEditor.init(),customCssInitialized=!0)}},SettingsPanel.prototype.updateSetting=function(e){var t=$(e).children().find('input[type="checkbox"]'),i=!t.is(":checked"),s=t.attr("id");t.prop("checked",i),"bda-css-2"==s&&($("#app-mount").removeClass("bd-hide-bd"),customCssEditor.hideBackdrop=i,i&&$("#app-mount").addClass("bd-hide-bd")),settingsCookie[s]=i,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 e=$(this).offset(),t=$(this).attr("alt");$(emoteNamePopup).find(".tipsy-inner").text(t),$(emoteNamePopup).css("left",e.left-25),$(emoteNamePopup).css("top",e.top-32),$("div[data-reactid='.0.1.1']").append($(emoteNamePopup))}),$(document).on("mouseleave",".emote",function(){$(".tipsy").remove()})):$(document).off("mouseover",".emote"),mainCore.saveSettings()},SettingsPanel.prototype.construct=function(){function e(){$(".tab-bar-item").removeClass("selected"),settingsButton.addClass("selected"),$(".form .settings-right .settings-inner").first().hide(),panel.show(),""==lastTab?i.changeTab("bd-settings-tab"):i.changeTab(lastTab)}function t(){$(".btn.btn-settings").length<1?setTimeout(t,100):$(".btn.btn-settings").first().on("click",function(){function e(){if($(".modal-inner").first().is(":visible")){panel.hide();var t=$(".tab-bar.SIDE").first();$(".tab-bar.SIDE .tab-bar-item").click(function(){$(".form .settings-right .settings-inner").first().show(),$("#bd-settings-new").removeClass("selected"),panel.hide()}),t.append(settingsButton),$(".form .settings-right .settings-inner").last().after(panel),$("#bd-settings-new").removeClass("selected")}else setTimeout(e,100)}e()})}var i=this;panel=$("<div/>",{id:"bd-pane","class":"settings-inner",css:{display:"none"}});var s='<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> <div class="bd-settings"> <div class="bd-pane control-group" id="bd-settings-pane" style="display:none;"> <ul class="checkbox-group">';for(var o in settings){var n=settings[o],a=n.id;"core"==n.cat&&n.implemented&&!n.hidden&&(s+='<li><div class="checkbox" onclick="settingsPanel.updateSetting(this);" ><div class="checkbox-inner"><input type="checkbox" id="'+a+'" '+(settingsCookie[a]?"checked":"")+"><span></span></div><span>"+o+" - "+n.info+"</span></div></li>");
}s+=" </ul> </div>",s+='<div class="bd-pane control-group" id="bd-emotes-pane" style="display:none;"> <ul class="checkbox-group">';for(var o in settings){var n=settings[o],a=n.id;"emote"==n.cat&&n.implemented&&!n.hidden&&(s+='<li><div class="checkbox" onclick="settingsPanel.updateSetting(this);" ><div class="checkbox-inner"><input type="checkbox" id="'+a+'" '+(settingsCookie[a]?"checked":"")+"><span></span></div><span>"+o+" - "+n.info+"</span></div></li>")}s+=" </ul> </div>";var d=atob(localStorage.getItem("bdcustomcss"));customCssEditor.applyCustomCss(d,!0,!1),s+=' <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">'+d+'</textarea></div> </div> <div class="bd-pane control-group" id="bd-plugins-pane" style="display:none;"> <table class="bd-g-table"> <thead><tr><th>Name</th><th>Description</th><th>Author</th><th>Version</th><th></th><th></th></tr></thead><tbody>',$.each(bdplugins,function(){var e=this.plugin;s+="<tr> <td>"+e.getName()+'</td> <td width="99%"><textarea>'+e.getDescription()+"</textarea></td> <td>"+e.getAuthor()+"</td> <td>"+e.getVersion()+'</td> <td><button class="bd-psb" onclick="pluginModule.showSettings(\''+e.getName()+'\'); return false;"></button></td> <td> <div class="checkbox" onclick="pluginModule.handlePlugin(this);"> <div class="checkbox-inner"> <input id="'+e.getName()+'" type="checkbox" '+(pluginCookie[e.getName()]?"checked":"")+"> <span></span> </div> </div> </td></tr>"}),s+='</tbody></table> </div> <div class="bd-pane control-group" id="bd-themes-pane" style="display:none;">',"undefined"==typeof themesupport2?s+=" Your version does not support themes. Download the latest version.":(s+=' <table class="bd-g-table"> <thead><tr><th>Name</th><th>Description</th><th>Author</th><th>Version</th><th></th></tr></thead><tbody>',$.each(bdthemes,function(){s+="<tr> <td>"+this.name.replace(/_/g," ")+'</td> <td width="99%"><textarea>'+this.description+"</textarea></td> <td>"+this.author+"</td> <td>"+this.version+'</td> <td> <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> </div> </td></tr>"}),s+="</tbody></table>"),s+=' </div> </div> </div> <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'+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> </div></div>',settingsButton=$("<div/>",{"class":"tab-bar-item",text:"BetterDiscord",id:"bd-settings-new",click:e}),panel.html(s),t()};var _hash;Utils.prototype.getTextArea=function(){return $(".channel-textarea-inner textarea")},Utils.prototype.jqDefer=function(e){window.jQuery?e():setTimeout(function(){this.jqDefer(e)},100)},Utils.prototype.getHash=function(){$.getJSON("https://api.github.com/repos/Jiiks/BetterDiscordApp/commits/master",function(e){_hash=e.sha,emoteModule.getBlacklist()})},Utils.prototype.loadHtml=function(e,t){var i=$("<div/>",{"class":"bd-container"}).appendTo("body");e="//cdn.rawgit.com/Jiiks/BetterDiscordApp/"+_hash+"/html/"+e+".html",i.load(e,t())},Utils.prototype.injectJs=function(e){$("<script/>",{type:"text/javascript",src:e}).appendTo($("body"))},Utils.prototype.injectCss=function(e){$("<link/>",{type:"text/css",rel:"stylesheet",href:e}).appendTo($("head"))},Utils.prototype.log=function(e){console.info("%c[BetterDiscord]%c "+e,"color:teal; font-weight:bold;","")},Utils.prototype.err=function(e){console.info("%c[BetterDiscord]%c "+e,"color:red; font-weight:bold;","")},VoiceMode.prototype.obsCallback=function(){var e=this;settingsCookie["bda-gs-4"]&&(e.disable(),setTimeout(function(){e.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 e=this.plugin;e.load();var t=e.getName(),i=!1;pluginCookie.hasOwnProperty(t)?i=pluginCookie[t]:pluginCookie[t]=!1,i&&e.start()})},PluginModule.prototype.handlePlugin=function(e){var t=$(e).children().find('input[type="checkbox"]'),i=!t.is(":checked"),s=t.attr("id");t.prop("checked",i),i?(bdplugins[s].plugin.start(),pluginCookie[s]=!0):(bdplugins[s].plugin.stop(),pluginCookie[s]=!1),this.savePluginData()},PluginModule.prototype.showSettings=function(e){if(null!=bdplugins[e]&&"function"==typeof bdplugins[e].plugin.getSettingsPanel){var t=bdplugins[e].plugin.getSettingsPanel();$(".modal-inner").off("click.bdpsm").on("click.bdpsm",function(e){$("#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(t)}},PluginModule.prototype.loadPluginData=function(){var e=$.cookie("bd-plugins");void 0!=e&&(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(e,t){$.each(bdplugins,function(){pluginCookie[this.plugin.getName()]&&"function"==typeof this.plugin.socketEvent&&this.plugin.socketEvent(t)})},PluginModule.prototype.rawObserver=function(e){$.each(bdplugins,function(){pluginCookie[this.plugin.getName()]&&"function"==typeof this.plugin.observer&&this.plugin.observer(e)})};var themeCookie={};ThemeModule.prototype.loadThemes=function(){this.loadThemeData(),$.each(bdthemes,function(){var e=this.name,t=!1;themeCookie.hasOwnProperty(e)?themeCookie[e]&&(t=!0):themeCookie[e]=!1,t&&$("head").append('<style id="'+e+'">'+unescape(bdthemes[e].css)+"</style>")})},ThemeModule.prototype.handleTheme=function(e){var t=$(e).children().find('input[type="checkbox"]'),i=!t.is(":checked"),s=t.attr("id").substring(2);t.prop("checked",i),i?($("head").append('<style id="'+s+'">'+unescape(bdthemes[s].css)+"</style>"),themeCookie[s]=!0):($("#"+s).remove(),themeCookie[s]=!1),this.saveThemeData()},ThemeModule.prototype.loadThemeData=function(){var e=$.cookie("bd-themes");void 0!=e&&(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(e){utils.log("Socket Host: "+e);try{bdSocket=new WebSocket(e),bdSocket.onopen=this.onOpen,bdSocket.onmessage=this.onMessage,bdSocket.onerror=this.onError,bdSocket.onclose=this.onClose}catch(t){utils.log(t)}},BdWSocket.prototype.onOpen=function(){utils.log("Socket Open");var e={op:2,d:{token:JSON.parse(localStorage.getItem("token")),properties:JSON.parse(localStorage.getItem("superProperties")),v:3}};bdws.send(e)},BdWSocket.prototype.onMessage=function(e){var t,i,s;try{t=JSON.parse(e.data),i=t.d,s=t.t}catch(o){return void utils.err(o)}switch(s){case"READY":bdSocket.interval=setInterval(function(){bdws.send({op:1,d:Date.now()})},i.heartbeat_interval),utils.log("Socket Ready");break;case"PRESENCE_UPDATE":pluginModule.socketEvent("PRESENCE_UPDATE",i);break;case"TYPING_START":pluginModule.socketEvent("TYPING_START",i);break;case"MESSAGE_CREATE":pluginModule.socketEvent("MESSAGE_CREATE",i);break;case"MESSAGE_UPDATE":pluginModule.socketEvent("MESSAGE_UPDATE",i)}},BdWSocket.prototype.onError=function(e){utils.log("Socket Error - "+e.message)},BdWSocket.prototype.onClose=function(e){utils.log("Socket Closed - "+e.code+" : "+e.reason),clearInterval(bdSocket.interval),bdws.start()},BdWSocket.prototype.send=function(e){1==bdSocket.readyState&&bdSocket.send(JSON.stringify(e))},BdWSocket.prototype.getSocket=function(){return bdSocket},BdApi.joinServer=function(e){opublicServers.joinServer(e)},BdApi.injectCSS=function(e,t){$("head").append('<style id="'+e+'"></style>'),$("#"+e).html(t)},BdApi.clearCSS=function(e){$("#"+e).remove()},BdApi.getPlugin=function(e){return bdplugins.hasOwnProperty(e)?bdplugins[e].plugin:null},BdApi.getIpc=function(){return betterDiscordIPC},BdApi.getCore=function(){return mainCore},BdApi.getUserIdByName=function(e){for(var t=$(".member-username"),i=0;i<t.length;i++){var s=$(t[i]);if(s.text()==e){var o=s.closest(".member").find(".avatar-small").css("background-image");return o.match(/\d+/)}}return null};var gg;BdApi.getUserNameById=function(e){for(var t=$(".avatar-small"),i=0;i<t.length;i++){var s=$(t[i]),o=s.css("background-image");if(e==o.match(/\d+/))return s.parent().find(".member-username").text()}return null},BdApi.setPlaying=function(e){bdws.send({op:3,d:{idle_since:null,game:{name:e}}})},BdApi.setStatus=function(e,t){bdws.send({op:3,d:{idle_since:e,game:{name:t}}})};