-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelix.js
80 lines (70 loc) · 2.27 KB
/
helix.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
let channel_name = '';
function collectHelix(channel_id) {
master_log('Call Helix with HelixToken for channel: ' + channel_id);
fetch(
'https://api.twitch.tv/helix/users/?id=' + channel_id,
{
method: 'GET',
headers: helix,
}
)
.then(resp => {
return resp.json();
})
.then(resp => {
master_log('Got Helix for channel');
document.getElementById('helix_log_channel').textContent = '';
var table = document.createElement('table');
document.getElementById('helix_log_channel').append(table);
for (var key in resp.data[0]) {
var tr = document.createElement('tr');
table.append(tr);
var td = document.createElement('td');
td.textContent = key;
tr.append(td);
var td = document.createElement('td');
td.textContent = resp.data[0][key];
tr.append(td);
}
channel_name = resp.data[0].login;
})
.catch(err => {
master_log('Got Helix for channel: failed');
console.log(err);
});
if (!window.Twitch.ext.viewer.isLinked) {
master_log('Call Helix with HelixToken for user: No Not Logged In');
return;
}
master_log('Call Helix with HelixToken for user: ' + window.Twitch.ext.viewer.id);
fetch(
'https://api.twitch.tv/helix/users/?id=' + window.Twitch.ext.viewer.id,
{
method: 'GET',
headers: helix,
}
)
.then(resp => {
return resp.json();
})
.then(resp => {
master_log('Got Helix for user');
document.getElementById('helix_log_user').textContent = '';
var table = document.createElement('table');
document.getElementById('helix_log_user').append(table);
for (var key in resp.data[0]) {
var tr = document.createElement('tr');
table.append(tr);
var td = document.createElement('td');
td.textContent = key;
tr.append(td);
var td = document.createElement('td');
td.textContent = resp.data[0][key];
tr.append(td);
}
})
.catch(err => {
master_log('Got Helix for user: failed');
console.log(err);
});
}