Fix for emote api changes

This commit is contained in:
Zack Rauen 2020-01-08 14:30:39 -05:00
parent 5cce246324
commit a9578b1d9e
5 changed files with 14 additions and 35 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -182,7 +182,7 @@ window.bdPluginStorage = class bdPluginStorage {
var settingsPanel, emoteModule, quickEmoteMenu, voiceMode, pluginModule, themeModule, dMode, publicServersModule; var settingsPanel, emoteModule, quickEmoteMenu, voiceMode, pluginModule, themeModule, dMode, publicServersModule;
var minSupportedVersion = "0.3.0"; var minSupportedVersion = "0.3.0";
var bbdVersion = "0.2.20"; var bbdVersion = "0.2.21";
var mainCore; var mainCore;
@ -679,48 +679,34 @@ EmoteModule.prototype.init = async function () {
let emoteInfo = { let emoteInfo = {
TwitchGlobal: { TwitchGlobal: {
url: "https://twitchemotes.com/api_cache/v3/global.json", url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_global.json`,
backup: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_global.json`,
variable: "TwitchGlobal", variable: "TwitchGlobal",
oldVariable: "emotesTwitch", oldVariable: "emotesTwitch",
getEmoteURL: (e) => `https://static-cdn.jtvnw.net/emoticons/v1/${e.id}/1.0`, getEmoteURL: (e) => `https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`
getOldData: (url, name) => { return {id: url.match(/\/([0-9]+)\//)[1], code: name, emoticon_set: 0, description: null}; }
}, },
TwitchSubscriber: { TwitchSubscriber: {
url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_subscriber.json`, url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_subscriber.json`,
variable: "TwitchSubscriber", variable: "TwitchSubscriber",
oldVariable: "subEmotesTwitch", oldVariable: "subEmotesTwitch",
getEmoteURL: (e) => `https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`, getEmoteURL: (e) => `https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`
getOldData: (url) => url.match(/\/([0-9]+)\//)[1]
}, },
FrankerFaceZ: { FrankerFaceZ: {
url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_ffz.json`, url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_ffz.json`,
variable: "FrankerFaceZ", variable: "FrankerFaceZ",
oldVariable: "emotesFfz", oldVariable: "emotesFfz",
getEmoteURL: (e) => `https://cdn.frankerfacez.com/emoticon/${e}/1`, getEmoteURL: (e) => `https://cdn.frankerfacez.com/emoticon/${e}/1`
getOldData: (url) => url.match(/\/([0-9]+)\//)[1]
}, },
BTTV: { BTTV: {
url: "https://api.betterttv.net/emotes", url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv.json`,
variable: "BTTV", variable: "BTTV",
oldVariable: "emotesBTTV", oldVariable: "emotesBTTV",
parser: (data) => { getEmoteURL: (e) => `https://cdn.betterttv.net/emote/${e}/1x`
let emotes = {};
for (let e = 0, len = data.emotes.length; e < len; e++) {
let emote = data.emotes[e];
emotes[emote.regex] = emote.url;
}
return emotes;
},
getEmoteURL: (e) => `${e}`,
getOldData: (url) => url
}, },
BTTV2: { BTTV2: {
url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv.json`, url: `https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv2.json`,
variable: "BTTV2", variable: "BTTV2",
oldVariable: "emotesBTTV2", oldVariable: "emotesBTTV2",
getEmoteURL: (e) => `https://cdn.betterttv.net/emote/${e}/1x`, getEmoteURL: (e) => `https://cdn.betterttv.net/emote/${e}/1x`
getOldData: (url) => url.match(/emote\/(.+)\//)[1]
} }
}; };
@ -820,14 +806,6 @@ EmoteModule.prototype.clearEmoteData = async function() {
}; };
}; };
EmoteModule.prototype.goBack = async function(emoteInfo) {
for (let e in emoteInfo) {
for (let emote in window.bdEmotes[emoteInfo[e].variable]) {
window[emoteInfo[e].oldVariable][emote] = emoteInfo[e].getOldData(window.bdEmotes[emoteInfo[e].variable][emote], emote);
}
}
};
EmoteModule.prototype.isCacheValid = function() { EmoteModule.prototype.isCacheValid = function() {
const cacheLength = DataStore.getBDData("emoteCacheDays") || DataStore.setBDData("emoteCacheDays", 7) || 7; const cacheLength = DataStore.getBDData("emoteCacheDays") || DataStore.setBDData("emoteCacheDays", 7) || 7;
const cacheDate = new Date(DataStore.getBDData("emoteCacheDate") || null); const cacheDate = new Date(DataStore.getBDData("emoteCacheDate") || null);

4
js/main.min.js vendored

File diff suppressed because one or more lines are too long