-
Notifications
You must be signed in to change notification settings - Fork 12
/
twitch-assets.js
50 lines (45 loc) · 1.72 KB
/
twitch-assets.js
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
var TW_URL = {}
TW_URL.ChannelBadges = (cid) =>
`https://badges.twitch.tv/v1/badges/channels/${cid}/display`;
TW_URL.GlobalBadges = () => `https://badges.twitch.tv/v1/badges/global/display`;
TW_URL.CheerEmotes = () => `https://api.twitch.tv/kraken/bits/actions`;
TW_URL.Emote = (id) => `https://static-cdn.jtvnw.net/emoticons/v1/${id}/1.0`;
TW_URL.Cheer = (p, t) =>
`https://d3aqoihi2n8ty8.cloudfront.net/actions/${p}/dark/animated/${t}/1.gif`;
function LoadChannelBadges(channelId, callback) {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (this.readyState == 4 && this.status === 200) {
var json = JSON.parse(this.responseText);
callback(json);
}
};
req.open("GET", TW_URL.ChannelBadges(channelId));
req.setRequestHeader("Accept", "application/vnd.twitchtv.v5+json");
req.send();
}
function LoadGlobalBadges(callback) {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (this.readyState == 4 && this.status === 200) {
var json = JSON.parse(this.responseText);
callback(json);
}
};
req.open("GET", TW_URL.GlobalBadges());
req.setRequestHeader("Accept", "application/vnd.twitchtv.v5+json");
req.send();
}
function LoadCheerEmotes(clientId, callback) {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (this.readyState == 4 && this.status === 200) {
var json = JSON.parse(this.responseText);
callback(json);
}
};
req.open("GET", TW_URL.CheerEmotes());
req.setRequestHeader("Accept", "application/vnd.twitchtv.v5+json");
req.setRequestHeader("Client-ID", clientId);
req.send();
}