forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
24 lines (22 loc) · 776 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
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
chrome.alarms.onAlarm.addListener(function() {
chrome.browserAction.setBadgeText({text: ''});
chrome.notifications.create({
type: 'basic',
iconUrl: 'stay_hydrated.png',
title: 'Time to Hydrate',
message: 'Everyday I\'m Guzzlin\'!',
buttons: [
{title: 'Keep it Flowing.'}
],
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});
});
});