-
Notifications
You must be signed in to change notification settings - Fork 9
/
background.js
33 lines (28 loc) · 861 Bytes
/
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
29
30
31
32
33
'use strict';
const quack = new Audio("resources/audio/quack.mp3");
chrome.alarms.onAlarm.addListener(function () {
chrome.browserAction.setBadgeText({text: ''});
chrome.storage.sync.get({
soundEnabled: true
}, function (result) {
if (result.soundEnabled) {
quack.play();
}
});
chrome.notifications.create({
type: 'basic',
iconUrl: 'resources/img/ducky.png',
title: 'Time\'s up!',
message: 'Quack!',
buttons: [
{title: 'You set an alarm to ring now.'}
],
priority: 0
});
});
chrome.notifications.onButtonClicked.addListener(function () {
chrome.storage.sync.get(['minutes'], function (item) {
chrome.browserAction.setBadgeText({text: 'ON'});
chrome.alarms.create({delayInMinutes: item.minutes});
});
});