-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
35 lines (32 loc) · 922 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
34
35
navigator.webkitPersistentStorage.queryUsageAndQuota(
function(usedBytes, grantedBytes) {
console.log("We are using", usedBytes, " of ", grantedBytes, " bytes");
},
function(e) {
console.log("Error", e);
}
);
var launchStoriesWeLove = function () {
chrome.app.window.create('story.html?storyID=14197693', {
outerBounds: {
width: 360,
height: 640
},
//alwaysOnTop: true,
resizable: false,
frame: {
type: 'chrome',
color: '#e69000'
}
});
};
var onNotificationsClicked = function(id) {
// Only launch if no other windows exist.
var windows = chrome.app.window.getAll();
if (windows && windows.length === 0) {
chrome.notifications.clear(id, function() {}); // Callback required.
launchStoriesWeLove();
}
};
chrome.app.runtime.onLaunched.addListener(launchStoriesWeLove);
chrome.notifications.onClicked.addListener(onNotificationsClicked);