BetterDiscordApp-v2/js/main.min.js

3 lines
243 KiB
JavaScript
Raw Normal View History

2015-12-15 10:13:40 +01:00
function Core(){}function EmoteModule(){}function PublicServers(){}function QuickEmoteMenu(){}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")}function Utils(){}function VoiceMode(){}function PluginModule(){}function ThemeModule(){}function BdApi(){}var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule,jsVersion=1.54,supportedVersion="0.2.3",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},"Public Servers":{id:"bda-gs-1",info:"Display public servers button",implemented:!0},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0},"Quick Emote Menu":{id:"bda-es-0",info:"Show quick emote menu for adding emotes",implemented:!0},"Show Emotes":{id:"bda-es-7",info:"Show any emotes",implemented:!0},"FrankerFaceZ Emotes":{id:"bda-es-1",info:"Show FrankerFaceZ Emotes",implemented:!0},"BetterTTV Emotes":{id:"bda-es-2",info:"Show BetterTTV Emotes",implemented:!0},"Emote Autocomplete":{id:"bda-es-3",info:"Autocomplete emote commands",implemented:!1},"Emote Auto Capitalization":{id:"bda-es-4",info:"Autocapitalize emote commands",implemented:!0},"Override Default Emotes":{id:"bda-es-5",info:"Override default emotes",implemented:!1},"Show Names":{id:"bda-es-6",info:"Show emote names on hover",implemented:!0}},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-es-0":!0,"bda-es-1":!1,"bda-es-2":!1,"bda-es-3":!1,"bda-es-4":!1,"bda-es-5":!0,"bda-es-6":!0,"bda-es-7":!0,"bda-jd":!0},bdchangelog={changes:{favemotes:{title:"Favorite Emotes!",text:"You can now favorite emotes and have them listed in the quick emote menu!",img:""},plugins:{title:"Plugins!",text:"Combined with Core 0.2.3, you can now write JavaScript plugins for Discord!",img:""},settingsmenu:{title:"Settings Menu!",text:"New and improved settings menu!",img:""},csseditor:{title:"New CSS Editor!",text:"New CSS Editor powered by <a href='http://codemirror.net' target='_blank'>CodeMirror!</a>",img:""},minimalmode:{title:"Minimal mode makeover!",text:"New and improved minimal mode!",img:""}},fixes:{reload:{title:"Reload Fix!",text:"Fixed an issue that caused Discord to crash on reload!",img:""},eemotes:{title:"Edit Emotes!",text:"Edited messages now display emotes properly!",img:""},pservers:{title:"Public Servers",text:"Public servers have been fixed!",img:""},other:{title:"Bugfixes!",text:"Several smaller bugs fixed!",img:""}},upcoming:{ignore:{title:"Ignore User!",text:"Ignore users you don't like!",img:""},themes:{title:"Custom themes!",text:"Write your own or download custom themes!",img:""},favemotes:{title:"Favorite emotes!",text:"Add your favorite emote(s) to the quick emote menu!",img:""},more:{title:"More Things!",text:"More things but probably not in the next version!",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 B=$(".guilds li:first-child");B.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
A.indexOf("nobottomsnow")>-1?$("#snowcover").remove():$("head").append("<style id=\"snowcover\">.flex-spacer.flex-vertical form { background-repeat: repeat no-repeat; background-position: bottom; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJkAAAAbCAYAAABvJC1pAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAEC3SURBVHgBAKdAWL8BpbK/APj5+gC8ydEA/wIBAAMCAgAAAAAA////AAYFBAAXEhEA4uXqADgwKAADAgQAGRYSAO7z8gDg5uoA9vj5AAMCAgD///8ADQ4MAAMEBAD+/v4AAAAAAO7y9ABBMSoCKCAcCiAZFf6rv8n2jKe6ACAYEwD4/f4A8Pf5AO3y9gBFMycvSjYsW8XW35sVEAvbFhENRQEAAkDN2uN9Eg0L/v3+/gD9/v4A/f7+AFI8LwACBAQAtc7YALbR2wBTNSsAFA8LAOr0+QAdFhEA+vv8AAAAAAAIBQQA5e/zANvp7QAlFhIA8Pf7AAYEAwDr9PYA4+/1AP7+AQADAgEA9/v8ABIKCABpQy0A3u71ALfW5gAWDQcAEQoFAOf0+AAOCQcADwkHAPf7/QDz+/wA+v3+AAIBAQAAAAAA/v//ABcKCAALBgMA5/L2APf6+wAaDAkA9Pn8ANzr8wA0HRMATy4dAKPF1wDI3OgAEgwIAP7/AAD+//4AFQwHACQVDwDt9fgAEwkGAPL4+AATDQoAGxEOAPn8/QAAAAAAAwICAPf5+gD//fwAAgABAKbF0QAsHBUAWTouAAwGBACxxtIA9/n8AAUEAwAHBQQA3+jtABsVD1stIRkM8/X3mtHd5QY6KiOE3+jrzZayw6gTDgsAEQsIAAwFBADS3uQAVkE0AIZnUwzd5OoH4ejs77XGzwAODAn+AQAAAAABAQABAAAA9PL0APz8/QACAgEA////AAoICAAtIx8A9fb5AP7//QC1wcsAK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gMA9fn8ADYiGADi7/MA/f7/AAMEAQAnGBE3LBsTQfv+/zD1+vr9BwQDHwQCAvwFBAMc6vP2Nsbc5cUeEw4AAAABAP8AAAACAQEAAAAAAAAAAAAAAAAAAgEBAAEBAQDH2eIAOykeADwtIQDf6u4WGxQPeQYEAvbw9PYA+Pv77+fk59gEAgIDPS0kXBIODDfp8PRs7vL2xujv8wD09vnSOi0kitrk6A/j6e7X9/j689vm6QDA0NsAzNTdAAD+/gBaRzcAOS8nABUPDQDu8/YACwkKLB0YEhP2+Pry/v/+J/r5/SJhUURxAwEBDMfR2OIkHhkzHRcUzf7//wAEBAMA3BUSAPn6+wAAAAAAA1NZYAD6+/wA+fr7ANDZ4ACgr7wAsLzHABkVEUNIPjOc0Nnguv79/uwvJiBV2+Ho0DowKEXF0Nm4x9Lar11MPTr5+/zuy9Xc9hANCwAeGRQA7vr7AEs7L0x4Xky9AAAAA9Hb47b6/P0FAAD/+f/+ALfe5+3Xvc3YACofF04FBQUnLSEaNeTs8dTh6e3MJRwWQcva4rI3KCBDCAYFCyEYEyj6+/2fvtPeAOrx9QBRNyoA6PD0AMnc5ADP4egALx8ZAA4KCAD5+/wADgkIAPz+/wAHAwMICgcGB9rp78M9JRxeCwcFDQUDAxUnGBBE4u7039Dk7I7u9vrc6vX4ABYOCgBJLB8A9fn7AOj0+ADx+PwAGxAKRT0hF3cKBgUL9vv9CTUbE3Y5HhRnAAAArxkMCfcdDwoAHA4KABIKBwBIJRmyJxQNbu
2015-12-15 08:38:21 +01:00
}),Q+="</tbody></table>"),Q+=" </div> </div> </div></div>",settingsButton=$("<div/>",{"class":"tab-bar-item",text:"BetterDiscord",id:"bd-settings-new",click:A}),panel.html(Q),D()};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,D){var B=$("<div/>",{"class":"bd-container"}).appendTo("body");A="//cdn.rawgit.com/Jiiks/BetterDiscordApp/"+_hash+"/html/"+A+".html",B.load(A,D())},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"))},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 D=A.getName(),B=!1;pluginCookie.hasOwnProperty(D)?B=pluginCookie[D]:pluginCookie[D]=!1,B&&A.start()})},PluginModule.prototype.handlePlugin=function(A){var D=$(A).children().find('input[type="checkbox"]'),B=!D.is(":checked"),Q=D.attr("id");D.prop("checked",B),B?(bdplugins[Q].plugin.start(),pluginCookie[Q]=!0):(bdplugins[Q].plugin.stop(),pluginCookie[Q]=!1),this.savePluginData()},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:"/"})};var themeCookie={};ThemeModule.prototype.loadThemes=function(){this.loadThemeData(),$.each(bdthemes,function(){var A=this.name,D=!1;themeCookie.hasOwnProperty(A)?themeCookie[A]&&(D=!0):themeCookie[A]=!1,D&&$("head").append('<style id="'+A+'">'+unescape(bdthemes[A].css)+"</style>")})},ThemeModule.prototype.handleTheme=function(A){var D=$(A).children().find('input[type="checkbox"]'),B=!D.is(":checked"),Q=D.attr("id").substring(2);D.prop("checked",B),B?($("head").append('<style id="'+Q+'">'+unescape(bdthemes[Q].css)+"</style>"),themeCookie[Q]=!0):($("#"+Q).remove(),themeCookie[Q]=!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:"/"})},BdApi.joinServer=function(A){opublicServers.joinServer(A)},BdApi.injectCSS=function(A,D){$("head").append('<style id="'+A+'"></style>'),$("#"+A).html(D)},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 D=$(".member-username"