-
Notifications
You must be signed in to change notification settings - Fork 4
/
background.js
28 lines (25 loc) · 1.08 KB
/
background.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
// SpaceAPI
var doorURL = 'https://www.hackerspace.gr/spaceapi';
// This function checks spaceapi to see if hsgr is open
function checker() {
$.ajax({
type: 'GET',
url: doorURL,
dataType: 'json',
success: function(data) {
if (data.state.open) {
chrome.browserAction.setTitle({title: 'HSGR is open with ' + (data.state.message).replace(/\D/g, '') + ' hackers'});
chrome.browserAction.setIcon({path: 'icons/openhsgr-32.png'});
chrome.browserAction.setBadgeText({text: (data.state.message).replace(/\D/g, '')});
chrome.browserAction.setBadgeBackgroundColor({color: '#808080'});
} else {
chrome.browserAction.setTitle({title: 'HSGR is closed'});
chrome.browserAction.setIcon({path: 'icons/hsgr-32.png'});
chrome.browserAction.setBadgeText({text: ''});
}
}
});
}
// This calls checker at start and every 15 minutes
checker();
setInterval(checker, 15 * 60 * 1000);