From 5ef27d7e1afe93c48595659bac1df82cb697025c Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Fri, 24 May 2019 16:11:17 -0400 Subject: [PATCH] small fix for pubservers for some --- js/main.js | 8 +++++--- js/main.min.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 792913a7..5f62f6d3 100644 --- a/js/main.js +++ b/js/main.js @@ -4746,6 +4746,7 @@ class V2C_PublicServers extends BDV2.reactComponent { withCredentials: true }, success: data => { + // Utils.log("PublicServer", "Got data: " + JSON.stringify(data)); self.setState({ selectedCategory: 0, connection: { @@ -4757,7 +4758,8 @@ class V2C_PublicServers extends BDV2.reactComponent { }, error: jqXHR => { - if (jqXHR.status === 403 || jqXHR.status === 404) { + // Utils.err("PublicServers", "Error on connection.", jqXHR); + // if (jqXHR.status === 403 || jqXHR.status === 404) { //Not connected self.setState({ title: "Not connected to discordservers.com!", @@ -4768,8 +4770,8 @@ class V2C_PublicServers extends BDV2.reactComponent { user: null } }); - return; - } + // return; + // } } }); } diff --git a/js/main.min.js b/js/main.min.js index bc118788..4f11b9e8 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -52,4 +52,4 @@ - `),o=[a(e),a(t)];n.find(".tab-bar-item").on("click",t=>{t.preventDefault(),n.find(".tab-bar-item").removeClass("selected"),$(t.target).addClass("selected"),n.find(".scroller").empty().append(o[$(t.target).index()])}),n.find(".footer button").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.find(".bd-backdrop").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.appendTo("#app-mount"),e.length?n.find(".tab-bar-item")[0].click():n.find(".tab-bar-item")[1].click()},Core.prototype.showToast=function(e,t={}){if(!bdConfig.deferLoaded)return;if(!document.querySelector(".bd-toasts")){let e=document.createElement("div");e.classList.add("bd-toasts");let t=document.querySelector(".chat-3bRxxu form, #friends, .noChannel-Z1DQK7, .activityFeed-28jde9");e.style.setProperty("left",t?t.getBoundingClientRect().left+"px":"0px"),e.style.setProperty("width",t?t.offsetWidth+"px":"100%"),e.style.setProperty("bottom",(document.querySelector(".chat-3bRxxu form")?document.querySelector(".chat-3bRxxu form").offsetHeight:80)+"px"),document.querySelector(".app, .app-2rEoOp").appendChild(e)}const{type:a="",icon:n=!0,timeout:o=3e3}=t;let s=document.createElement("div");s.classList.add("bd-toast"),a&&s.classList.add("toast-"+a),a&&n&&s.classList.add("icon"),s.innerText=e,document.querySelector(".bd-toasts").appendChild(s),setTimeout(()=>{s.classList.add("closing"),setTimeout(()=>{s.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},o)},window.emotesFfz={},window.emotesBTTV={},window.emotesBTTV2={},window.emotesTwitch={},window.subEmotesTwitch={},window.bdEmotes={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},window.bdEmoteSettingIDs={TwitchGlobal:"bda-es-7",TwitchSubscriber:"bda-es-7",BTTV:"bda-es-2",FrankerFaceZ:"bda-es-1",BTTV2:"bda-es-2"};function EmoteModule(){Object.defineProperty(this,"categories",{get:function(){const e=[];for(const t in window.bdEmoteSettingIDs)settingsCookie[window.bdEmoteSettingIDs[t]]&&e.push(t);return e}})}EmoteModule.prototype.init=async function(){this.modifiers=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],this.overrides=["twitch","bttv","ffz"];let e={TwitchGlobal:{url:"https://twitchemotes.com/api_cache/v3/global.json",backup:`https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_global.json`,variable:"TwitchGlobal",oldVariable:"emotesTwitch",getEmoteURL:t=>`https://static-cdn.jtvnw.net/emoticons/v1/${t.id}/1.0`,getOldData:(e,t)=>({id:e.match(/\/([0-9]+)\//)[1],code:t,emoticon_set:0,description:null})},TwitchSubscriber:{url:`https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_subscriber.json`,variable:"TwitchSubscriber",oldVariable:"subEmotesTwitch",getEmoteURL:t=>`https://static-cdn.jtvnw.net/emoticons/v1/${t}/1.0`,getOldData:e=>e.match(/\/([0-9]+)\//)[1]},FrankerFaceZ:{url:`https://rauenzi.github.io/BetterDiscordApp/data/emotedata_ffz.json`,variable:"FrankerFaceZ",oldVariable:"emotesFfz",getEmoteURL:t=>`https://cdn.frankerfacez.com/emoticon/${t}/1`,getOldData:e=>e.match(/\/([0-9]+)\//)[1]},BTTV:{url:"https://api.betterttv.net/emotes",variable:"BTTV",oldVariable:"emotesBTTV",parser:t=>{let a={};for(let n,o=0,e=t.emotes.length;o`${t}`,getOldData:e=>e},BTTV2:{url:`https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv.json`,variable:"BTTV2",oldVariable:"emotesBTTV2",getEmoteURL:t=>`https://cdn.betterttv.net/emote/${t}/1x`,getOldData:e=>e.match(/emote\/(.+)\//)[1]}};for(await this.getBlacklist(),await this.loadEmoteData(e);!BDV2.MessageContentComponent;)await new Promise(e=>setTimeout(e,100));this.cancelEmoteRender||(this.cancelEmoteRender=Utils.monkeyPatch(BDV2.MessageContentComponent.prototype,"render",{after:({returnValue:e})=>{Utils.monkeyPatch(e.props,"children",{silent:!0,after:({returnValue:e})=>{if(0!=this.categories.length){const t=e.props.children[1];if(t.props.children){const e=t.props.children[1];if(e&&e.length){for(let t=0;ti.length||bemotes.includes(i))continue;this.modifiers.includes(l)&&settingsCookie["bda-es-8"]||(l=""),this.overrides.includes(d)?l=d:d="";let c=this.categories[a];if("twitch"===d?window.bdEmotes.TwitchGlobal[i]?c="TwitchGlobal":window.bdEmotes.TwitchSubscriber[i]&&(c="TwitchSubscriber"):"bttv"===d?window.bdEmotes.BTTV[i]?c="BTTV":window.bdEmotes.BTTV2[i]&&(c="BTTV2"):"ffz"===d&&window.bdEmotes.FrankerFaceZ[i]&&(c="FrankerFaceZ"),!window.bdEmotes[c][i]||!settingsCookie[window.bdEmoteSettingIDs[c]])continue;const p=e[t].match(new RegExp(`([\\s]|^)${Utils.escape(l?i+":"+l:i)}([\\s]|$)`));if(!p)continue;const m=e[t].substring(0,p.index+p[1].length),u=e[t].substring(p.index+p[0].length-p[2].length);e[t]=m;const h=BDV2.react.createElement(BDEmote,{name:i,url:window.bdEmotes[c][i],modifier:l});e.splice(t+1,0,u),e.splice(t+1,0,h)}}const t=e.every(e=>"string"==typeof e&&""==e.replace(/\s*/,"")||!!(e.type&&"BDEmote"==e.type.name)||!!(e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName));if(t)for(let t of e)"object"==typeof t&&("BDEmote"==t.type.name?t.props.jumboable=!0:t.props&&t.props.children&&t.props.children.props&&t.props.children.props.emojiName&&(t.props.children.props.jumboable=!0))}}}}})}}))},EmoteModule.prototype.disable=function(){this.disableAutoCapitalize();this.cancelEmoteRender||(this.cancelEmoteRender(),this.cancelEmoteRender=null)},EmoteModule.prototype.clearEmoteData=async function(){let e=require("fs"),t=bdConfig.dataPath+"emote_data.json",a=e.existsSync(t);a&&e.unlinkSync(t),DataStore.setBDData("emoteCacheDate",new Date().toJSON()),window.bdEmotes={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}}},EmoteModule.prototype.goBack=async function(t){for(let a in t)for(let e in window.bdEmotes[t[a].variable])window[t[a].oldVariable][e]=t[a].getOldData(window.bdEmotes[t[a].variable][e],e)},EmoteModule.prototype.isCacheValid=function(){const e=new Date(DataStore.getBDData("emoteCacheDate")||null),t=new Date,a=Math.round(Math.abs((t.getTime()-e.getTime())/86400000));return!(a>bdConfig.cache.days)||(DataStore.setBDData("emoteCacheDate",t.toJSON()),!1)},EmoteModule.prototype.loadEmoteData=async function(t){const a=require("fs"),n=bdConfig.dataPath+"emote_data.json",o=a.existsSync(n);if(o&&this.isCacheValid()){settingsCookie["fork-ps-2"]&&mainCore.showToast("Loading emotes from cache.",{type:"info"}),Utils.log("Emotes","Loading emotes from local cache.");const o=await new Promise(e=>{a.readFile(n,"utf8",(t,a)=>{Utils.log("Emotes","Emotes loaded from cache."),t&&(a={}),e(a)})});let s=Utils.testJSON(o);for(const a in s&&(window.bdEmotes=JSON.parse(o)),t)s=0setTimeout(e,1e3));let e=await this.downloadEmotes(t[a]);window.bdEmotes[t[a].variable]=e}settingsCookie["fork-ps-2"]&&mainCore.showToast("All emotes successfully downloaded.",{type:"success"});try{a.writeFileSync(n,JSON.stringify(window.bdEmotes),"utf8")}catch(e){Utils.err("Emotes","Could not save emote data.",e)}}},EmoteModule.prototype.downloadEmotes=function(e){let t=require("request"),a={url:e.url,timeout:e.timeout?e.timeout:5e3};return Utils.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((n,o)=>{t(a,(t,a,s)=>{if(t)return Utils.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),n(this.downloadEmotes(e))):o({});let r={};try{r=JSON.parse(s)}catch(t){return Utils.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),n(this.downloadEmotes(e))):o({})}for(let n in"function"==typeof e.parser&&(r=e.parser(r)),r){if(4>n.length||bemotes.includes(n)){delete r[n];continue}r[n]=e.getEmoteURL(r[n])}n(r),Utils.log("Emotes","Downloaded: "+e.variable)})})},EmoteModule.prototype.getBlacklist=function(){return new Promise(e=>{$.getJSON(`https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json`,function(t){e(bemotes=t.blacklist)})})};var bemotes=[];EmoteModule.prototype.autoCapitalize=function(){!settingsCookie["bda-es-4"]||this.autoCapitalizeActive||($("body").on("keyup.bdac change.bdac paste.bdac",$(".channelTextArea-1LDbYG textarea:first"),()=>{var e=$(".channelTextArea-1LDbYG textarea:first").val();if(null!=e){var t=e.split(" ").pop();if(3",t+=" ",t+=" ",t+="