-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
36 lines (31 loc) · 983 Bytes
/
popup.js
File metadata and controls
36 lines (31 loc) · 983 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
let cheapSecsEl = document.getElementById('cheap_seconds');
let date = document.getElementById('date');
let bonus = document.getElementById('bonus');
date.textContent = new Date().toLocaleString();
function secondsToString(seconds) {
dateObj = new Date(seconds * 1000);
hours = dateObj.getUTCHours();
minutes = dateObj.getUTCMinutes();
seconds = dateObj.getSeconds();
return (
hours.toString().padStart(2, '0') +
':' +
minutes.toString().padStart(2, '0') +
':' +
seconds.toString().padStart(2, '0')
);
}
async function my_usage() {
const response = await chrome.runtime.sendMessage({
give_me: 'my_current_usage',
});
cheapSecsEl.textContent = secondsToString(response['your_usage_is']);
date.textContent =
new Date().toLocaleString() +
' (' +
(response['you_are'] ? 'suspended' : 'not suspended') +
')';
bonus.textContent = secondsToString(response['your_bonus_is']);
}
my_usage();
setInterval(my_usage, 1000);