-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
48 lines (38 loc) · 1.35 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Sounds On Awards</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
<script src="./reconnecting-websocket.min.js"></script>
<script src="./PubSub.js"></script>
<script src="./config.js"></script>
</head>
<body>
<div id="notificator">
<img id="rewardImage" src="">
</div>
<script>
const PubSub = new TwitchPubSub(config.channelInfo.id, config.channelInfo.name);
PubSub.addEventListener("reward-redeemed", {
handleEvent: (ev) => {
let redemption = ev.data.redemption;
let reward = redemption.reward;
console.log(redemption);
console.log("Reward ID:", reward.id);
let sound = config.sounds[reward.id];
if(!sound) return;
let imageUrl = reward.image ? reward.image.url_4x : reward.default_image.url_4x;
let rewardImage = document.getElementById("rewardImage");
rewardImage.style.opacity = 1;
rewardImage.src = imageUrl;
let audio = new Audio("sounds/" + sound);
audio.play();
audio.addEventListener("ended", () => {
rewardImage.style.opacity = 0;
});
}
});
</script>
</body>
</html>