1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
function Core(){}function EmoteModule(){}function PublicServers(){}function QuickEmoteMenu(){}function SettingsPanel(){}function Utils(){}function VoiceMode(){}var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,jsVersion=1.52,supportedVersion="0.1.5",mainObserver,twitchEmoteUrlStart="https://static-cdn.jtvnw.net/emoticons/v1/",twitchEmoteUrlEnd="/1.0",ffzEmoteUrlStart="https://cdn.frankerfacez.com/emoticon/",ffzEmoteUrlEnd="/1",bttvEmoteUrlStart="",bttvEmoteUrlEnd="",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:null,fixes:{compact:{title:"Compact Mode Emotes!",text:"Compact Mode Emotes have been fixed and should now be visible!",img:""}},upcoming:{ignore:{title:"Ignore User!",text:"Ignore users you don't like",img:""},more:{title:"More Things!",text:"More things but probably not in the next version.",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");i.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"})))));var s=$("<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(s),opublicServers=new PublicServers,settingsPanel=new SettingsPanel,settingsPanel.init(),quickEmoteMenu.init(!1),$("#tc-settings-button").on("click",function(){settingsPanel.show()}),$("#bd-pub-button").on("click",function(){opublicServers.show()}),opublicServers.init(),emoteModule.autoCapitalize(),settingsCookie.version<jsVersion){var o=t.constructChangelog();$("body").append(o),settingsCookie.version=jsVersion,t.saveSettings()}$("head").append('<script>Date.now||(Date.now=function(){return(new Date).getTime()}),function(){"use strict";for(var t=["webkit","moz"],e=0;e<t.length&&!window.requestAnimationFrame;++e){var i=t[e];window.requestAnimationFrame=window[i+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i+"CancelAnimationFrame"]||window[i+"CancelRequestAnimationFrame"]}if(/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent)||!window.requestAnimationFrame||!window.cancelAnimationFrame){var s=0;window.requestAnimationFrame=function(t){var e=Date.now(),i=Math.max(s+16,e);return setTimeout(function(){t(s=i)},i-e)},window.cancelAnimationFrame=clearTimeout}}(),function(t){t.snowfall=function(e,i){function s(s,n,a,o){this.x=s,this.y=n,this.size=a,this.speed=o,this.step=0,this.stepSize=h(1,10)/100,i.collection&&(this.target=m[h(0,m.length-1)]);var r=null;i.image?(r=document.createElement("img"),r.src=i.image):(r=document.createElement("div"),t(r).css({background:i.flakeColor})),t(r).attr({"class":"snowfall-flakes"}).css({width:this.size,height:this.size,position:i.flakePosition,top:this.y,left:this.x,fontSize:0,zIndex:i.flakeIndex}),t(e).get(0).tagName===t(document).get(0).tagName?(t("body").append(t(r)),e=t("body")):t(e).append(t(r)),this.element=r,this.update=function(){if(this.y+=this.speed,this.y>l-(this.size+6)&&this.reset(),this.element.style.top=this.y+"px",this.element.style.left=this.x+"px",this.step+=this.stepSize,this.x+=y===!1?Math.cos(this.step):y+Math.cos(this.step),i.collection&&this.x>this.target.x&&this.x<this.target.width+this.target.x&&this.y>this.target.y&&this.y<this.target.height+this.target.y){var t=this.target.element.getContext("2d"),e=this.x-this.target.x,s=this.y-this.target.y,n=this.target.colData;if(void 0!==n[parseInt(e)][parseInt(s+this.speed+this.size)]||s+this.speed+this.size>this.target.height)if(s+this.speed+this.size>this.target.height){for(;s+this.speed+this.size>this.target.height&&this.speed>0;)this.speed*=.5;t.fillStyle="#fff",void 0==n[parseInt(e)][parseInt(s+this.speed+this.size)]?(n[parseInt(e)][parseInt(s+this.speed+this.size)]=1,t.fillRect(e,s+this.speed+this.size,this.size,this.size)):(n[parseInt(e)][parseInt(s+this.speed)]=1,t.fillRect(e,s+this.speed,this.size,this.size)),this.reset()}else this.speed=1,this.stepSize=0,parseInt(e)+1<this.target.width&&void 0==n[parseInt(e)+1][parseInt(s)+1]?this.x++:parseInt(e)-1>0&&void 0==n[parseInt(e)-1][parseInt(s)+1]?this.x--:(t.fillStyle="#fff",t.fillRect(e,s,this.size,this.size),n[parseInt(e)][parseInt(s)]=1,this.reset())}(this.x+this.size>d-c||this.x<c)&&this.reset()},this.reset=function(){this.y=0,this.x=h(c,d-c),this.stepSize=h(1,10)/100,this.size=h(100*i.minSize,100*i.maxSize)/100,this.element.style.width=this.size+"px",this.element.style.height=this.size+"px",this.speed=h(i.minSpeed,i.maxSpeed)}}function n(){for(r=0;r<a.length;r+=1)a[r].update();f=requestAnimationFrame(function(){n()})}var a=[],o={flakeCount:35,flakeColor:"#ffffff",flakePosition:"absolute",flakeIndex:999999,minSize:1,maxSize:2,minSpeed:1,maxSpeed:5,round:!1,shadow:!1,collection:!1,collectionHeight:40,deviceorientation:!1},i=t.extend(o,i),h=function(t,e){return Math.round(t+Math.random()*(e-t))};t(e).data("snowfall",this);var r=0,l=t(e).height(),d=t(e).width(),c=0,f=0;if(i.collection!==!1){var p=document.createElement("canvas");if(p.getContext&&p.getContext("2d"))for(var m=[],w=t(i.collection),g=i.collectionHeight,r=0;r<w.length;r++){var u=w[r].getBoundingClientRect(),x=t("<canvas/>",{"class":"snowfall-canvas"}),z=[];if(u.top-g>0){t("body").append(x),x.css({position:i.flakePosition,left:u.left+"px",top:u.top-g+"px"}).prop({width:u.width,height:g});for(var v=0;v<u.width;v++)z[v]=[];m.push({element:x.get(0),x:u.left,y:u.top-g,width:u.width,height:g,colData:z})}}else i.collection=!1}for(t(e).get(0).tagName===t(document).get(0).tagName&&(c=25),t(window).bind("resize",function(){l=t(e)[0].clientHeight,d=t(e)[0].offsetWidth}),r=0;r<i.flakeCount;r+=1)a.push(new s(h(c,d-c),h(0,l),h(100*i.minSize,100*i.maxSize)/100,h(i.minSpeed,i.maxSpeed)));i.round&&t(".snowfall-flakes").css({"-moz-border-radius":i.maxSize,"-webkit-border-radius":i.maxSize,"border-radius":i.maxSize}),i.shadow&&t(".snowfall-flakes").css({"-moz-box-shadow":"1px 1px 1px #555","-webkit-box-shadow":"1px 1px 1px #555","box-shadow":"1px 1px 1px #555"});var y=!1;i.deviceorientation&&t(window).bind("deviceorientation",function(t){y=.1*t.originalEvent.gamma}),n(),this.clear=function(){t(".snowfall-canvas").remove(),t(e).children(".snowfall-flakes").remove(),cancelAnimationFrame(f)}},t.fn.snowfall=function(e){return"object"==typeof e||void 0==e?this.each(function(){new t.snowfall(this,e)}):"string"==typeof e?this.each(function(){var e=t(this).data("snowfall");e&&e.clear()}):void 0}}(jQuery);</script>')}else setTimeout(e,100)}var t=this;return version<supportedVersion?void alert("BetterDiscord v"+version+"(your version) is not supported by the latest js("+jsVersion+"). Please download the latest version from GitHub."):(utils=new Utils,utils.getHash(),emoteModule=new EmoteModule,quickEmoteMenu=new QuickEmoteMenu,voiceMode=new VoiceMode,emoteModule.init(),this.initSettings(),this.initObserver(),void $(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"))},Core.prototype.initObserver=function(){mainObserver=new MutationObserver(function(e){e.forEach(function(e){null!=e.target.getAttribute("class")&&-1!=e.target.getAttribute("class").indexOf("titlebar")&&(quickEmoteMenu.obsCallback(),voiceMode.obsCallback()),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="change-log"> <div class="header"> <strong>What\'s new in BetterDiscord JS v'+jsVersion+'</strong> <button class="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-->'};var emotesFfz={},emotesBTTV={},emotesTwitch={emotes:{emote:{image_id:0}}},subEmotesTwitch={},twitchAc={"4head":"4Head",anele:"ANELE",argieb8:"ArgieB8",arsonnosexy:"ArsonNoSexy",asianglow:"AsianGlow",atgl:"AtGL",athenapms:"AthenaPMS",ativy:"AtIvy",atww:"AtWW",babyrage:"BabyRage",batchest:"BatChest",bcwarrior:"BCWarrior",biblethump:"BibleThump",bigbrother:"BigBrother",bionicbunion:"BionicBunion",blargnaut:"BlargNaut",bloodtrail:"BloodTrail",bort:"BORT",brainslug:"BrainSlug",brokeback:"BrokeBack",buddhabar:"BuddhaBar",coolcat:"CoolCat",corgiderp:"CorgiDerp",cougarhunt:"CougarHunt",daesuppy:"DAESuppy",dansgame:"DansGame",dathass:"DatHass",datsheffy:"DatSheffy",dbstyle:"DBstyle",deexcite:"deExcite",deilluminati:"deIlluminati",dendiface:"DendiFace",dogface:"DogFace",doomguy:"DOOMGuy",eagleeye:"EagleEye",elegiggle:"EleGiggle",evilfetus:"EvilFetus",failfish:"FailFish",fpsmarksman:"FPSMarksman",frankerz:"FrankerZ",freakinstinkin:"FreakinStinkin",fungineer:"FUNgineer",funrun:"FunRun",fuzzyotteroo:"FuzzyOtterOO",gasjoker:"GasJoker",gingerpower:"GingerPower",grammarking:"GrammarKing",hassanchop:"HassanChop",heyguys:"HeyGuys",hotpokket:"HotPokket",humblelife:"HumbleLife",itsboshytime:"ItsBoshyTime",jebaited:"Jebaited",jkanstyle:"JKanStyle",joncarnage:"JonCarnage",kapow:"KAPOW",kappa:"Kappa",kappapride:"KappaPride",keepo:"Keepo",kevinturtle:"KevinTurtle",kippa:"Kippa",kreygasm:"Kreygasm",kzskull:"KZskull",mau5:"Mau5",mcat:"mcaT",mechasupes:"MechaSupes",mrdestructoid:"MrDestructoid",mvgame:"MVGame",nightbat:"NightBat",ninjatroll:"NinjaTroll",nonospot:"NoNoSpot",notatk:"NotATK",notlikethis:"NotLikeThis",omgscoots:"OMGScoots",onehand:"OneHand",opieop:"OpieOP",optimizeprime:"OptimizePrime",osbeaver:"OSbeaver",osbury:"OSbury",osdeo:"OSdeo",osfrog:"OSfrog",oskomodo:"OSkomodo",osrob:"OSrob",ossloth:"OSsloth",panicbasket:"panicBasket",panicvis:"PanicVis",pazpazowitz:"PazPazowitz",peopleschamp:"PeoplesChamp",permasmug:"PermaSmug",picomause:"PicoMause",pipehype:"PipeHype",pjharley:"PJHarley",pjsalt:"PJSalt",pmstwin:"PMSTwin",pogchamp:"PogChamp",poooound:"Poooound",praiseit:"PraiseIt",prchase:"PRChase",punchtrees:"PunchTrees",puppeyface:"PuppeyFace",raccattack:"RaccAttack",ralpherz:"RalpherZ",redcoat:"RedCoat",residentsleeper:"ResidentSleeper",ritzmitz:"RitzMitz",rulefive:"RuleFive",shadylulu:"ShadyLulu",shazam:"Shazam",shazamicon:"shazamicon",shazbotstix:"ShazBotstix",shibez:"ShibeZ",smorc:"SMOrc",smskull:"SMSkull",sobayed:"SoBayed",soonerlater:"SoonerLater",srihead:"SriHead",ssssss:"SSSsss",stonelightning:"StoneLightning",strawbeary:"StrawBeary",supervinlin:"SuperVinlin",swiftrage:"SwiftRage",tbbaconbiscuit:"tbBaconBiscuit",tbchickenbiscuit:"tbChickenBiscuit",tbquesarito:"tbQuesarito",tbsausagebiscuit:"tbSausageBiscuit",tbspicy:"tbSpicy",tbsriracha:"tbSriracha",tf2john:"TF2John",theking:"TheKing",theringer:"TheRinger",thetarfu:"TheTarFu",thething:"TheThing",thunbeast:"ThunBeast",tinyface:"TinyFace",toospicy:"TooSpicy",trihard:"TriHard",ttours:"TTours",uleetbackup:"UleetBackup",unclenox:"UncleNox",unsane:"UnSane",vaultboy:"VaultBoy",volcania:"Volcania",wholewheat:"WholeWheat",winwaker:"WinWaker",wtruck:"WTRuck",wutface:"WutFace",youwhy:"YouWHY"};EmoteModule.prototype.init=function(){},EmoteModule.prototype.getBlacklist=function(){$.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/"+_hash+"/emotefilter.json",function(e){bemotes=e.blacklist})},EmoteModule.prototype.obsCallback=function(e){var t=this;if(settingsCookie["bda-es-7"])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){if("undefined"!=typeof emotesTwitch&&e.parentElement){var t=e.parentElement;if("SPAN"==t.tagName&&($(t.parentElement).hasClass("markup")||$(t.parentElement).hasClass("message-content"))){var i=t.innerHTML,s=i.split(/\s+/g);if(s&&(s.some(function(e){if("[!s]"==e.slice(0,4)){i=i.replace("[!s]","");var s=$(t).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(-1==$.inArray(e,bemotes)&&!(e.length<4)){if(emotesTwitch.emotes.hasOwnProperty(e)){if(settingsCookie["bda-es-6"]){var n=Math.round(e.length/4);return void(i=i.replace(e,'<img title="'+e.substr(0,n)+""+e.substr(n,n)+""+e.substr(2*n,n)+""+e.substr(3*n)+'" src="'+twitchEmoteUrlStart+emotesTwitch.emotes[e].image_id+twitchEmoteUrlEnd+'" />'))}return void(i=i.replace(e,"<img src="+twitchEmoteUrlStart+emotesTwitch.emotes[e].image_id+twitchEmoteUrlEnd+" ></img>"))}if("undefined"!=typeof emotesFfz&&settingsCookie["bda-es-1"]&&emotesFfz.hasOwnProperty(e)){if(settingsCookie["bda-es-6"]){var n=Math.round(e.length/4);return void(i=i.replace(e,'<img title="'+e.substr(0,n)+""+e.substr(n,n)+""+e.substr(2*n,n)+""+e.substr(3*n)+'" src="'+ffzEmoteUrlStart+emotesFfz[e]+ffzEmoteUrlEnd+'" />'))}return void(i=i.replace(e,"<img src="+ffzEmoteUrlStart+emotesFfz[e]+ffzEmoteUrlEnd+" ></img>"))}if("undefined"!=typeof emotesBTTV&&settingsCookie["bda-es-2"]&&emotesBTTV.hasOwnProperty(e)){if(settingsCookie["bda-es-6"]){var n=Math.round(e.length/4);return void(i=i.replace(e,'<img title="'+e.substr(0,n)+""+e.substr(n,n)+""+e.substr(2*n,n)+""+e.substr(3*n)+'" src="'+emotesBTTV[e]+'" />'))}return void(i=i.replace(e,"<img src="+emotesBTTV[e]+" ></img>"))}if(subEmotesTwitch.hasOwnProperty(e)){if(settingsCookie["bda-es-6"]){var n=Math.round(e.length/4);return void(i=i.replace(e,'<img title="'+e.substr(0,n)+""+e.substr(n,n)+""+e.substr(2*n,n)+""+e.substr(3*n)+'" src="'+twitchEmoteUrlStart+subEmotesTwitch[e]+twitchEmoteUrlEnd+'" />'))}return void(i=i.replace(e,"<img src="+twitchEmoteUrlStart+subEmotesTwitch[e]+twitchEmoteUrlEnd+" ></img>"))}}}),null!=t.parentElement)){var o=t.parentElement.offsetHeight;t.innerHTML=i.replace(new RegExp("","g"),"");var n=t.parentElement.offsetHeight,a=$(".scroller.messages").first();a.scrollTop(a.scrollTop()+(n-o))}}}},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){var s=e.capitalize(i.toLowerCase());null!=s&&$(".channel-textarea-inner textarea").val(t.replace(i,s))}}}})},EmoteModule.prototype.capitalize=function(e){return twitchAc.hasOwnProperty(e)?twitchAc[e]:null};var publicServers={servers:{server:{code:0,icon:null,title:"title",language:"EN",description:"description"}}};PublicServers.prototype.getPanel=function(){return this.container},PublicServers.prototype.init=function(){var e=this;this.container=$("<div/>",{id:"bd-ps-container",style:"display:none"});var t=$("<div/>",{id:"bd-ps-header"});$("<h2/>",{text:"Public Servers"}).appendTo(t),$("<span/>",{id:"bd-ps-close",style:"cursor:pointer;",text:"X"}).appendTo(t),t.appendTo(this.getPanel());var i=$("<div/>",{id:"bd-ps-body"});i.appendTo(this.getPanel());var s=$("<table/>",{border:"0"}),o=$("<thead/>");o.appendTo(s);var n=$("<tr/>",{}).append($("<th/>",{text:"Name"})).append($("<th/>",{text:"Code"})).append($("<th/>",{text:"Language"})).append($("<th/>",{text:"Description"})).append($("<th/>",{text:"Join"}));n.appendTo(o);var a=$("<tbody/>",{id:"bd-ps-tbody"});a.appendTo(s),s.appendTo(i),$("body").append(this.getPanel()),$("#bd-ps-close").on("click",function(){e.show()});var r=publicServers.servers;for(var l in r)if(r.hasOwnProperty(l)){var d=r[l],c=d.code,p=d.title,h=d.language,u=d.description;this.addServer(l,c,p,h,u)}},PublicServers.prototype.addServer=function(e,t,i,s,o){var n=this,a=$("#bd-ps-tbody"),r=$("<td/>").append($("<div/>",{"class":"bd-ps-description",text:o})),l=$("<tr/>");l.append($("<td/>",{text:i})),l.append($("<td/>",{css:{"-webkit-user-select":"initial","user-select":"initial"},text:t})),l.append($("<td/>",{text:s})),l.append(r),l.append($("<td/>").append($("<button/>",{text:"Join",css:{height:"30px",display:"block","margin-top":"10px","background-color":"#36393E",border:"1px solid #404040",outline:"1px solid #000",color:"#EDEDED"},click:function(){n.joinServer(t)}}))),a.append(l)},PublicServers.prototype.show=function(){this.getPanel().toggle();var e=$("#bd-pub-li");e.removeClass(),this.getPanel().is(":visible")&&e.addClass("active")},PublicServers.prototype.joinServer=function(e){$(".guilds-add").click(),$(".action.join .btn").click(),$(".create-guild-container input").val(e),$(".form.join-server .btn-primary").click()};var emoteBtn,emoteMenu;QuickEmoteMenu.prototype.init=function(e){emoteBtn=null,$(".channel-textarea").first().removeClass("emotemenu-enabled"),emoteMenu||this.initEmoteList();var t;emoteBtn=$("<div/>",{id:"twitchcord-button-container",style:"display:none"}).append($("<button/>",{id:"twitchcord-button",onclick:"return false;"})),$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn),emoteMenu.detach(),emoteBtn.append(emoteMenu),$("#twitchcord-button").on("click",function(){t=!t,t?(emoteMenu.addClass("emotemenu-open"),$(this).addClass("twitchcord-button-open")):(emoteMenu.removeClass(),$(this).removeClass())}),settingsCookie["bda-es-0"]&&($(".channel-textarea").first().addClass("emotemenu-enabled"),emoteBtn.show());var i=$(".emote-icon");i.off(),i.on("click",function(){var e=$(this).attr("id"),t=$(".channel-textarea-inner textarea");t.val(" "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)})},QuickEmoteMenu.prototype.obsCallback=function(){if(("/channels/86004744966914048/86004744966914048"==window.location.pathname||$("#customcss").html().indexOf("snow")>-1)&&-1==$("#customcss").html().indexOf("nosnow")&&($(".scroller.messages").snowfall("clear"),$(".scroller.messages").snowfall({flakeCount:100,maxSpeed:10})),emoteBtn&&$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form")){var e=$("#twitchcord-button-container");void 0==e.parent().prop("tagName")&&(quickEmoteMenu=new QuickEmoteMenu,quickEmoteMenu.init(!0))}},QuickEmoteMenu.prototype.initEmoteList=function(){emoteMenu=$("<div/>",{id:"emote-menu"});var e=$("<div/>",{id:"emote-menu-header"}).append($("<span/>",{text:"Global Emotes"})),t=$("<div/>",{id:"emote-menu-inner"});emoteMenu.append(e),emoteMenu.append(t);for(var i in emotesTwitch.emotes)if(emotesTwitch.emotes.hasOwnProperty(i)){var s=emotesTwitch.emotes[i].image_id;t.append($("<div/>",{"class":"emote-container"}).append($("<img/>",{"class":"emote-icon",id:i,alt:"",src:"https://static-cdn.jtvnw.net/emoticons/v1/"+s+"/1.0",title:i})))}};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-jd"]&&(opublicServers.joinServer("0Tmfo5ZbORCRqbAd"),settingsCookie["bda-jd"]=!1,mainCore.saveSettings())},SettingsPanel.prototype.applyCustomCss=function(e){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),$("#customcss").html(e),localStorage.setItem("bdcustomcss",btoa(e))},SettingsPanel.prototype.construct=function(){function e(){var e=$(this).children().find('input[type="checkbox"]'),t=!e.is(":checked"),i=e.attr("id");e.prop("checked",t),settingsCookie[i]=t,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(),mainCore.saveSettings()}function t(){$(".tab-bar-item").removeClass("selected"),settingsButton.addClass("selected"),$(".form .settings-right .settings-inner").first().hide(),panel.show()}function i(){$(".btn.btn-settings").length<1?setTimeout(i,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),panel.insertAfter(".form .settings-right .settings-inner"),$("#bd-settings-new").removeClass("selected")}else setTimeout(e,100)}e()})}var s=this;panel=$("<div/>",{"class":"settings-inner",style:"display:none;"});var o=$("<div/>",{"class":" scroller-wrap polyfil"});panel.append(o);var n=$("<div/>",{"class":"scroller settings-wrapper settings-panel"}),a=$("<div/>",{"class":"scrollbar"}).append($("<div/>",{"class":"track"}).append($("<div/>",{"class":"thumb"})));n.append(a),o.append(n);var r=$("<div/>",{"class":"control-groups"}),l=$("<div/>",{"class":"control-groups"});n.append(r),n.append(l);var d=$("<div/>",{"class":"control-group"}),c=$("<div/>",{"class":"control-group"});r.append(d),l.append(c),d.append($("<label/>",{text:"BetterDiscord Settings"})),c.append($("<label/>",{text:"Custom CSS"}));var p=$("<textarea/>",{id:"custom-css-ta"}),h=atob(localStorage.getItem("bdcustomcss"));s.applyCustomCss(h),p.val(h),c.append(p),p.on("input propertychange",function(){s.applyCustomCss($(this).val())});var u=$("<ul/>",{"class":"checkbox-group"});for(var m in settings){var g=settings[m],b=g.id;g.implemented&&u.append($("<li/>").append($("<div/>",{"class":"checkbox",click:e}).append($("<div/>",{"class":"checkbox-inner"}).append($("<input/>",{type:"checkbox",id:b,prop:{checked:settingsCookie[b]}})).append($("<span/>"))).append($("<span/>",{text:m+" - "+g.info}))))}d.append(u);var f=$("<div/>",{css:{background:"#1A1A1A",color:"#ADADAD",height:"30px",position:"absolute",bottom:"0",left:"0",right:"0"}}),v=$("<span/>",{text:"BetterDiscord v"+version+"(JSv"+jsVersion+") by Jiiks",css:{"line-height":"30px","margin-left":"10px"}}),w=$("<span/>",{css:{"float":"right","line-height":"30px","margin-right":"10px"}});for(var k in links)$("<a/>",{text:links[k].text,href:links[k].href,target:links[k].target}).append($("<span/>",{text:" | "})).appendTo(w);f.append(v),f.append(w),o.append(f),settingsButton=$("<div/>",{"class":"tab-bar-item",text:"BetterDiscord",id:"bd-settings-new",click:t}),i()};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()})},VoiceMode.prototype.obsCallback=function(){console.log("voiceMode obs");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","")}; |