-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (27 loc) · 797 Bytes
/
background.js
File metadata and controls
35 lines (27 loc) · 797 Bytes
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
// -- set up notifications
var messages = [];
function gotNotifications(data) {
var new_messages = [];
$.each(data, function(key, val) {
var messageContent = val.html;
if (messages.indexOf(messageContent) == -1){
chrome.browserAction.setBadgeText({'text': 'New'});
chrome.browserAction.setBadgeBackgroundColor({'color': '#668823'});
}
new_messages.push(messageContent);
});
messages = new_messages;
}
function checkNotifications() {
$.ajax({
url: 'https://inkdit.com/n.json',
dataType: 'json',
headers: {
// jQuery doesn't send this header on cross-domain requests by default.
"X-Requested-With": "XMLHttpRequest"
},
success: gotNotifications
});
}
checkNotifications();
setInterval(checkNotifications, 5000);