1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<!DOCTYPE html>
<html>
<head>
<title>chat widget</title>
<link rel="stylesheet" href="/style.css">
</head>
<body class="messages" id="messages">
<noscript>
JavaScript is required.
</noscript>
</body>
<script src="/scripts/emotes.js"></script>
<script src="/scripts/chat.js"></script>
<script src="/scripts/badges.js"></script>
<script>
let user = null;
const params = {};
const badges = {};
const emotes = {};
window.addEventListener("load", () => {
for (const [k, v] of new URLSearchParams(window.location.search)) {
params[k] = v;
}
if (!("channel" in params)) {
addSystemMessage("No channel specified!");
return;
}
fetch(`https://api.ivr.fi/v2/twitch/user?login=${params["channel"]}`)
.then((r) => r.json())
.then((json) => {
if (json.length == 0) {
addSystemMessage(`Channel #${params["channel"]} does not exist.`);
return;
}
user = json[0];
connectToChat("wss://irc-ws.chat.twitch.tv", "justinfan12345", "65432", user["login"]);
getTwitchBadges(user["login"], badges);
// adding emotes
const emotePromises = [
() => getFFZChannelEmotes(user["id"], emotes),
() => getFFZGlobalEmotes(emotes),
() => getBetterTTVGlobalEmotes(emotes),
() => getBetterTTVChannelEmotes(user["id"], emotes),
() => get7TVChannelEmotes(user["id"], emotes),
() => get7TVGlobalEmotes(emotes),
];
emotePromises
.reduce((p, fn) => p.then(fn), Promise.resolve())
.then(() => addSystemMessage("All emotes loaded"));
});
});
</script>
</html>
|