Zzzclock
Description:
ZzzClock is a chrome extension that display the approximate time on the extension's "badge". It's not really easy to see . The badge's background color will be blue and some times red, I am not going to explain it. Please take a look at the source code below.
Privacy policy:
The ZzzClock chrome extension does not transmit any data. It also does not collect or store any data. The only data it uses (to display the time) is the current time on your computer.
Support:
There is no support.
Source code:
Please take a look at the source code.
manifest.json:
{
"name": "ZzzClock",
"description": "Some kind of clock",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": ["alarms"],
"action": {
}
}
background.js
// background.js
console.log("blah");
SetBadgeTime();
chrome.alarms.create('alarm', {
delayInMinutes: 0, periodInMinutes: 0.5});
function SetBadgeTime() {
const myWindow = 5;
const n = new Date();
let hours = n.getHours();
let minutes = n.getMinutes();
let m = minutes % 30;
if ((m <= 30 && 30 - m < myWindow) || (m > 30 && m - 30 < myWindow)) {
chrome.action.setBadgeBackgroundColor({color: 'orange'});
} else {
chrome.action.setBadgeBackgroundColor({color: 'blue'});
}
chrome.action.setBadgeText({ text: hours.toString() + ":" + minutes.toString()});
}
chrome.alarms.onAlarm.addListener(function(alarm) {
SetBadgeTime();
});