-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMinisterIn.js
35 lines (32 loc) · 942 Bytes
/
MinisterIn.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
var isOpen = false;
function checkStatus(text) {
let num = parseInt(text, 10);
if (num > 0) {
chrome.browserAction.setTitle({ title: 'λspace is open' });
chrome.browserAction.setBadgeText({ text: num.toString() });
chrome.browserAction.setBadgeBackgroundColor({ color: '#808080' });
chrome.browserAction.setIcon({
path: {
48: 'icons/o_48x48.png',
96: 'icons/o_96x96.png'
}
});
} else {
chrome.browserAction.setTitle({ title: 'λspace is closed' });
chrome.browserAction.setBadgeText({ text: '' });
chrome.browserAction.setIcon({
path: {
48: 'icons/c_48x48.png',
96: 'icons/c_96x96.png'
}
});
}
}
function timer() {
fetch('https://api.lambdaspace.gr/api/v2.0/status')
.then(response => response.json())
.then(data => checkStatus(data.people_now_present))
.catch(e => console.error(e));
}
timer();
setInterval(timer, 300000);