Skip to content

Commit 0d8c6e2

Browse files
committed
Pronouns + Tiktok/Kick Gift Bold Styling
1 parent 53bfb53 commit 0d8c6e2

8 files changed

Lines changed: 113 additions & 52 deletions

File tree

chat.html

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/simple-notify.min.css">
1414
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css">
1515

16-
<link rel="stylesheet" href="css/chatrd.css?nocache=35">
16+
<link rel="stylesheet" href="css/chatrd.css?nocache=36">
1717
<link id="chatrd-skins" rel="stylesheet" href="css/skin-default.css">
1818
</head>
1919
<body>
@@ -170,42 +170,42 @@
170170
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script>
171171
<script src="https://cdn.jsdelivr.net/npm/@streamerbot/[email protected]/dist/streamerbot-client.min.js"></script>
172172

173-
<script src="js/i18n-chatrd.js?nocache=35"></script>
173+
<script src="js/i18n-chatrd.js?nocache=36"></script>
174174

175-
<script src="js/speakerbot.js?nocache=35"></script>
176-
<script src="js/sb.js?nocache=35"></script>
175+
<script src="js/speakerbot.js?nocache=36"></script>
176+
<script src="js/sb.js?nocache=36"></script>
177177

178-
<script src="js/chatrd.js?nocache=35"></script>
178+
<script src="js/chatrd.js?nocache=36"></script>
179179

180-
<link href="js/modules/twitch/module.css?nocache=35" rel="stylesheet">
181-
<script src="js/modules/twitch/module.js?nocache=35"></script>
180+
<link href="js/modules/twitch/module.css?nocache=36" rel="stylesheet">
181+
<script src="js/modules/twitch/module.js?nocache=36"></script>
182182

183-
<link href="js/modules/youtube/module.css?nocache=35" rel="stylesheet">
184-
<script src="js/modules/youtube/module.js?nocache=35"></script>
183+
<link href="js/modules/youtube/module.css?nocache=36" rel="stylesheet">
184+
<script src="js/modules/youtube/module.js?nocache=36"></script>
185185

186-
<link href="js/modules/tiktok/module.css?nocache=35" rel="stylesheet">
187-
<script src="js/modules/tiktok/module.js?nocache=35"></script>
186+
<link href="js/modules/tiktok/module.css?nocache=36" rel="stylesheet">
187+
<script src="js/modules/tiktok/module.js?nocache=36"></script>
188188

189-
<link href="js/modules/kick/module.css?nocache=35" rel="stylesheet">
190-
<script src="js/modules/kick/module.js?nocache=35"></script>
189+
<link href="js/modules/kick/module.css?nocache=36" rel="stylesheet">
190+
<script src="js/modules/kick/module.js?nocache=36"></script>
191191

192-
<link href="js/modules/streamelements/module.css?nocache=35" rel="stylesheet">
193-
<script src="js/modules/streamelements/module.js?nocache=35"></script>
192+
<link href="js/modules/streamelements/module.css?nocache=36" rel="stylesheet">
193+
<script src="js/modules/streamelements/module.js?nocache=36"></script>
194194

195-
<link href="js/modules/streamlabs/module.css?nocache=35" rel="stylesheet">
196-
<script src="js/modules/streamlabs/module.js?nocache=35"></script>
195+
<link href="js/modules/streamlabs/module.css?nocache=36" rel="stylesheet">
196+
<script src="js/modules/streamlabs/module.js?nocache=36"></script>
197197

198-
<link href="js/modules/patreon/module.css?nocache=35" rel="stylesheet">
199-
<script src="js/modules/patreon/module.js?nocache=35"></script>
198+
<link href="js/modules/patreon/module.css?nocache=36" rel="stylesheet">
199+
<script src="js/modules/patreon/module.js?nocache=36"></script>
200200

201-
<link href="js/modules/tipeeestream/module.css?nocache=35" rel="stylesheet">
202-
<script src="js/modules/tipeeestream/module.js?nocache=35"></script>
201+
<link href="js/modules/tipeeestream/module.css?nocache=36" rel="stylesheet">
202+
<script src="js/modules/tipeeestream/module.js?nocache=36"></script>
203203

204-
<link href="js/modules/kofi/module.css?nocache=35" rel="stylesheet">
205-
<script src="js/modules/kofi/module.js?nocache=35"></script>
204+
<link href="js/modules/kofi/module.css?nocache=36" rel="stylesheet">
205+
<script src="js/modules/kofi/module.js?nocache=36"></script>
206206

207-
<link href="js/modules/fourthwall/module.css?nocache=35" rel="stylesheet">
208-
<script src="js/modules/fourthwall/module.js?nocache=35"></script>
207+
<link href="js/modules/fourthwall/module.css?nocache=36" rel="stylesheet">
208+
<script src="js/modules/fourthwall/module.js?nocache=36"></script>
209209

210210
</body>
211211
</html>

js/modules/twitch/module.js

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ const showTwitchViewers = getURLParam("showTwitchViewers", true);
2828
const twitchStreamer = {};
2929

3030
const twitchAvatars = new Map();
31-
const twitchPronouns = new Map();
31+
3232
const twitchGoals = new Map();
3333

34+
let supportedPronouns = null;
35+
const twitchPronouns = new Map();
36+
3437
const bitsGifAnimations = [
3538
{ min: 1, max: 99, gifId: 1 },
3639
{ min: 100, max: 999, gifId: 100 },
@@ -1805,7 +1808,7 @@ async function getTwitchMessageFromParts(parts) {
18051808
}
18061809

18071810

1808-
async function getTwitchUserPronouns(username) {
1811+
/*async function getTwitchUserPronouns(username) {
18091812
if (twitchPronouns.has(username)) {
18101813
console.debug(`Pronouns found for ${username}. Getting it from Map...`);
18111814
return twitchPronouns.get(username);
@@ -1828,20 +1831,78 @@ async function getTwitchUserPronouns(username) {
18281831
console.error(`Couldn't retrieve pronouns for ${username}:`, err);
18291832
return '';
18301833
}
1834+
}*/
1835+
1836+
1837+
1838+
async function getTwitchUserPronouns(username) {
1839+
1840+
if (!supportedPronouns) {
1841+
try {
1842+
console.debug('[ChatRD] Trying to fetch supported pronouns...');
1843+
const res = await fetch('https://pronouns.alejo.io/api/pronouns');
1844+
supportedPronouns = await res.json();
1845+
}
1846+
catch (err) {
1847+
console.error('[ChatRD] Could not fetch supported pronouns:', err);
1848+
return '';
1849+
}
1850+
}
1851+
1852+
if (twitchPronouns.has(username)) {
1853+
console.debug(`[ChatRD] Pronouns found for ${username}. Getting it from Map...`);
1854+
return twitchPronouns.get(username);
1855+
}
1856+
1857+
console.debug(`[ChatRD] Pronouns not found for ${username} in the Map! Retrieving...`);
1858+
1859+
try {
1860+
const res = await fetch(`https://api.pronouns.alejo.io/v1/users/${username}`);
1861+
const data = await res.json();
1862+
1863+
if (data === 'not_found') {
1864+
console.debug(`[ChatRD] No pronouns found for ${username}. Setting it to empty...`);
1865+
twitchPronouns.set(username, '');
1866+
return '';
1867+
}
1868+
1869+
console.debug(`[ChatRD] Got pronouns for ${username}:`, data);
1870+
1871+
const pronounId = data?.pronoun_id ?? null;
1872+
const altPronounId = data?.alt_pronoun_id ?? null;
1873+
1874+
const mainMatch = pronounId ? supportedPronouns.find(p => p.name === pronounId) : null;
1875+
1876+
let pronoun = mainMatch ? mainMatch.display : '';
1877+
1878+
if (altPronounId !== null) {
1879+
const altDisplay = altPronounId === 'any' ? 'Any' : supportedPronouns.find(p => p.name === altPronounId)?.display ?? null;
1880+
if (altDisplay) pronoun += `/${altDisplay}`;
1881+
}
1882+
1883+
const formatted = pronoun ? `<em>${pronoun}</em>` : '';
1884+
1885+
twitchPronouns.set(username, formatted);
1886+
return formatted;
1887+
}
1888+
catch (err) {
1889+
console.error(`[ChatRD] Couldn't retrieve pronouns for ${username}:`, err);
1890+
return '';
1891+
}
18311892
}
18321893

18331894
function twitchConfettiBurst(el) {
1834-
const rect = el.getBoundingClientRect();
1835-
1836-
myConfetti({
1837-
particleCount: 100,
1838-
spread: 135,
1839-
startVelocity: 20,
1840-
gravity: 1.5,
1841-
ticks: 80,
1842-
origin: {
1843-
x: (rect.left + rect.width / 2) / window.innerWidth,
1844-
y: (rect.top + rect.height / 2) / window.innerHeight,
1845-
},
1846-
});
1895+
const rect = el.getBoundingClientRect();
1896+
1897+
myConfetti({
1898+
particleCount: 100,
1899+
spread: 135,
1900+
startVelocity: 20,
1901+
gravity: 1.5,
1902+
ticks: 80,
1903+
origin: {
1904+
x: (rect.left + rect.width / 2) / window.innerWidth,
1905+
y: (rect.top + rect.height / 2) / window.innerHeight,
1906+
},
1907+
});
18471908
}

locale/de.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@
149149
"likes_action": " hat dir ",
150150
"likes_singular": "Like gesendet",
151151
"likes_plural": "Likes gesendet",
152-
"gift_action": " hat dir {count} {name} geschenkt",
152+
"gift_action": " hat dir <strong>{count} {name}</strong> geschenkt",
153153
"sub_action": " hat gerade den Kanal abonniert."
154154
},
155155

156156
"kick": {
157157
"follow_action": " folgt jetzt dem Kanal",
158-
"kicksgift_action": " hat ein {name} gesendet ",
158+
"kicksgift_action": " hat ein <strong>{name}</strong> gesendet ",
159159
"kicks_singular": "Kick",
160160
"kicks_plural": "Kicks",
161161
"sub_action": " hat für ",

locale/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@
149149
"likes_action": " sent you ",
150150
"likes_singular": "like",
151151
"likes_plural": "likes",
152-
"gift_action": " gifted you {count} {name}",
152+
"gift_action": " gifted you <strong>{count} {name}</strong>",
153153
"sub_action": " just subscribed to the channel."
154154
},
155155

156156
"kick": {
157157
"follow_action": " followed the channel",
158-
"kicksgift_action": " sent a {name} ",
158+
"kicksgift_action": " sent a <strong>{name}</strong> ",
159159
"kicks_singular": "Kick",
160160
"kicks_plural": "Kicks",
161161
"sub_action": " subscribed for ",

locale/es-ES.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@
149149
"likes_action": " envió ",
150150
"likes_singular": "me gusta",
151151
"likes_plural": "me gustas",
152-
"gift_action": " te regaló {count} {name}",
152+
"gift_action": " te regaló <strong>{count} {name}</strong>",
153153
"sub_action": " acaba de suscribirse al canal."
154154
},
155155

156156
"kick": {
157157
"follow_action": " ha seguido el canal",
158-
"kicksgift_action": " envió un {name} ",
158+
"kicksgift_action": " envió un <strong>{name}</strong> ",
159159
"kicks_singular": "Kick",
160160
"kicks_plural": "Kicks",
161161
"sub_action": " se suscribió por ",

locale/pl.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@
149149
"likes_action": " wysłał ci ",
150150
"likes_singular": "polubienie",
151151
"likes_plural": "polubień",
152-
"gift_action": " podarował ci {count} {name}",
152+
"gift_action": " podarował ci <strong>{count} {name}</strong>",
153153
"sub_action": " właśnie zasubskrybował kanał."
154154
},
155155

156156
"kick": {
157157
"follow_action": " obserwuje kanał",
158-
"kicksgift_action": " wysłał {name} ",
158+
"kicksgift_action": " wysłał <strong>{name}</strong> ",
159159
"kicks_singular": "Kick",
160160
"kicks_plural": "Kicków",
161161
"sub_action": " subskrybuje od ",

locale/pt-BR.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@
149149
"likes_action": " enviou ",
150150
"likes_singular": "curtida",
151151
"likes_plural": "curtidas",
152-
"gift_action": " presenteou você com {count} {name}",
152+
"gift_action": " presenteou você com <strong>{count} {name}</strong>",
153153
"sub_action": " acabou de se inscrever no canal."
154154
},
155155

156156
"kick": {
157157
"follow_action": " seguiu o canal",
158-
"kicksgift_action": " enviou um {name} ",
158+
"kicksgift_action": " enviou um <strong>{name}</strong> ",
159159
"kicks_singular": "Kick",
160160
"kicks_plural": "Kicks",
161161
"sub_action": " se inscreveu por ",

locale/tl-PH.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@
149149
"likes_action": " nagpadala sa iyo ng ",
150150
"likes_singular": "like",
151151
"likes_plural": "mga like",
152-
"gift_action": " nagbigay sa iyo ng {count} {name}",
152+
"gift_action": " nagbigay sa iyo ng <strong>{count} {name}</strong>",
153153
"sub_action": " nag-subscribe sa channel."
154154
},
155155

156156
"kick": {
157157
"follow_action": " ay nag-follow",
158-
"kicksgift_action": " nagpadala ng {name} ",
158+
"kicksgift_action": " nagpadala ng <strong>{name}</strong> ",
159159
"kicks_singular": "Kick",
160160
"kicks_plural": "Kicks",
161161
"sub_action": " nag-subscribe ng ",

0 commit comments

Comments
 (0)