diff options
| author | ilotterytea <iltsu@alright.party> | 2025-10-26 00:56:39 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-10-26 00:56:39 +0500 |
| commit | 747f552eee9e45d017b810ab438ac91d1dbd2b70 (patch) | |
| tree | 4c8724c1cabccbd8cd4afd23106ece92f811bb4e | |
| parent | 0ac966b46700a725b155309147912c7dc53740b2 (diff) | |
feat: ffz emotes
| -rw-r--r-- | scripts/emotes.js | 39 | ||||
| -rw-r--r-- | twitch.html | 2 |
2 files changed, 41 insertions, 0 deletions
diff --git a/scripts/emotes.js b/scripts/emotes.js index 84f9901..f99bb44 100644 --- a/scripts/emotes.js +++ b/scripts/emotes.js @@ -46,4 +46,43 @@ function get7TVGlobalEmotes(emotes) { emotes[e["name"]] = `https://cdn.7tv.app/emote/${e["id"]}/1x.webp`; } }); +} + +function getFFZChannelEmotes(twitchId, emotes) { + return fetch(`https://api.frankerfacez.com/v1/room/id/${twitchId}`) + .then((r) => r.json()) + .then((json) => { + if ("error" in json) { + addSystemMessage(`${json["error"]} (FFZ)`); + return; + } + + const room = json["room"]; + + if ("moderator_badge" in room) { + badges["moderator/1"] = room["moderator_badge"]; + } + + if ("vip_badge" in room) { + badges["vip/1"] = room["vip_badge"]["1"]; + } + + if (room["set"] in json["sets"]) { + for (const e of json["sets"][room["set"]]["emoticons"]) { + emotes[e["name"]] = e["urls"]["1"]; + } + } + }); +} + +function getFFZGlobalEmotes(emotes) { + return fetch(`https://api.frankerfacez.com/v1/set/global`) + .then((r) => r.json()) + .then((json) => { + for (const id of json["default_sets"]) { + for (const e of json["sets"][id]["emoticons"]) { + emotes[e["name"]] = e["urls"]["1"]; + } + } + }); }
\ No newline at end of file diff --git a/twitch.html b/twitch.html index deafbff..ff77bca 100644 --- a/twitch.html +++ b/twitch.html @@ -42,6 +42,8 @@ // adding emotes const emotePromises = [ + () => getFFZChannelEmotes(user["id"], emotes), + () => getFFZGlobalEmotes(emotes), () => getBetterTTVGlobalEmotes(emotes), () => getBetterTTVChannelEmotes(user["id"], emotes), () => get7TVChannelEmotes(user["id"], emotes), |
