From 0ac966b46700a725b155309147912c7dc53740b2 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 26 Oct 2025 00:17:05 +0500 Subject: feat: 7tv emotes --- scripts/emotes.js | 25 +++++++++++++++++++++++++ twitch.html | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/emotes.js b/scripts/emotes.js index 96bc103..84f9901 100644 --- a/scripts/emotes.js +++ b/scripts/emotes.js @@ -21,4 +21,29 @@ function getBetterTTVGlobalEmotes(emotes) { emotes[e["code"]] = `https://cdn.betterttv.net/emote/${e["id"]}/1x.webp`; } }); +} + +function get7TVChannelEmotes(twitchId, emotes) { + return fetch(`https://7tv.io/v3/users/twitch/${twitchId}`) + .then((r) => r.json()) + .then((json) => { + if ("error" in json) { + addSystemMessage(`${json["error"]} (7TV)`); + return; + } + + for (const e of json["emote_set"]["emotes"]) { + emotes[e["name"]] = `https://cdn.7tv.app/emote/${e["id"]}/1x.webp`; + } + }); +} + +function get7TVGlobalEmotes(emotes) { + return fetch(`https://7tv.io/v3/emote-sets/global`) + .then((r) => r.json()) + .then((json) => { + for (const e of json["emotes"]) { + emotes[e["name"]] = `https://cdn.7tv.app/emote/${e["id"]}/1x.webp`; + } + }); } \ No newline at end of file diff --git a/twitch.html b/twitch.html index d606b48..deafbff 100644 --- a/twitch.html +++ b/twitch.html @@ -42,8 +42,10 @@ // adding emotes const emotePromises = [ + () => getBetterTTVGlobalEmotes(emotes), () => getBetterTTVChannelEmotes(user["id"], emotes), - () => getBetterTTVGlobalEmotes(emotes) + () => get7TVChannelEmotes(user["id"], emotes), + () => get7TVGlobalEmotes(emotes), ]; emotePromises .reduce((p, fn) => p.then(fn), Promise.resolve()) -- cgit v1.2.3