-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
41 lines (31 loc) · 789 Bytes
/
background.js
File metadata and controls
41 lines (31 loc) · 789 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
36
37
38
39
40
41
function startTimeout(seconds) {
var ms = seconds * 1000,
tick = 0,
now = Date.now(),
interval;
chrome.browserAction.setBadgeText({
text: String(seconds)
});
interval = setInterval(function () {
var remaining;
tick++;
console.log('ticked ' + tick);
if (tick === seconds) {
clearInterval(interval);
chrome.browserAction.setBadgeText({
text: ''
});
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
name: 'debugger'
});
});
} else {
remaining = seconds - tick;
// Set badge text to countdown
chrome.browserAction.setBadgeText({
text: String(remaining)
});
}
}, 1000);
}