diff options
| author | ilotterytea <iltsu@alright.party> | 2025-10-26 21:48:53 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-10-26 21:48:53 +0500 |
| commit | 5069975b6987d42a2c3d15a8e95d546cd8c743eb (patch) | |
| tree | bf6563c18e1d293e7a3e91badfe76a0fcc5bd493 | |
| parent | c3465bddcbb1da935160b0f0612e6616ab927279 (diff) | |
feat: tinyemotes support
| -rw-r--r-- | scripts/emotes.js | 45 | ||||
| -rw-r--r-- | twitch.html | 12 |
2 files changed, 56 insertions, 1 deletions
diff --git a/scripts/emotes.js b/scripts/emotes.js index f0b329a..7f73688 100644 --- a/scripts/emotes.js +++ b/scripts/emotes.js @@ -85,4 +85,49 @@ function getFFZGlobalEmotes(emotes) { } } }); +} + +function getTinyemotesChannelEmotes(instance, twitchId, emotes) { + fetch(`${instance}/users.php?alias_id=${twitchId}`, { + headers: { + 'Accept': 'application/json' + } + }) + .then((r) => r.json()) + .then((json) => { + if (json.status_code != 200) { + addSystemMessage(`${json.message} (${instance})`); + return; + } + + const data = json["data"]; + + const set_id = data["active_emote_set_id"]; + + const emote_set = data["emote_sets"].find((x) => x["id"] == set_id); + if (emote_set) { + for (const e of emote_set["emotes"]) { + emotes[e["code"]] = `${instance}/static/userdata/emotes/${e["id"]}/1x.webp`; + } + } + }); +} + +function getTinyemotesGlobalEmotes(instance, emotes) { + fetch(`${instance}/emotesets.php?id=global`, { + headers: { + 'Accept': 'application/json' + } + }) + .then((r) => r.json()) + .then((json) => { + if (json.status_code != 200) { + addSystemMessage(`${json.message} (${instance})`); + return; + } + + for (const e of json["data"]["emotes"]) { + emotes[e["code"]] = `${instance}/static/userdata/emotes/${e["id"]}/1x.webp`; + } + }); }
\ No newline at end of file diff --git a/twitch.html b/twitch.html index ff77bca..9adc40c 100644 --- a/twitch.html +++ b/twitch.html @@ -15,7 +15,9 @@ <script src="/scripts/badges.js"></script> <script> let user = null; - const params = {}; + const params = { + "tinyemotesinstances": null + }; const badges = {}; const emotes = {}; @@ -49,6 +51,14 @@ () => get7TVChannelEmotes(user["id"], emotes), () => get7TVGlobalEmotes(emotes), ]; + + if (params["tinyemotesinstances"] != null) { + for (const url of params["tinyemotesinstances"].split("\n")) { + emotePromises.push(() => getTinyemotesChannelEmotes(url, user["id"], emotes)); + emotePromises.push(() => getTinyemotesGlobalEmotes(url, emotes)); + } + } + emotePromises .reduce((p, fn) => p.then(fn), Promise.resolve()) .then(() => addSystemMessage("All emotes loaded")); |
