-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfiguration.js
54 lines (47 loc) · 1.32 KB
/
configuration.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;(function () {
var DEFAULT_CONFIGURATION = {
showOnlineNotifications: true,
showUnreadNotifications: true,
fireOnInactiveTab : true,
expirationTime : null,
messageKeywords : '',
muteAllExcept : '',
playSound : false,
iconClickURL : '',
disabledUrls : [],
}
var configuration = {
DEFAULT: DEFAULT_CONFIGURATION,
forEachDefault: function(callback) {
for (var prop in DEFAULT_CONFIGURATION) {
callback(prop, DEFAULT_CONFIGURATION[prop])
}
},
get: function(key, callback) {
if (typeof key === 'function') {
callback = key
chrome.storage.sync.get(DEFAULT_CONFIGURATION, callback)
} else {
chrome.storage.sync.get(key, function(result) {
callback(result[key])
})
}
},
set: function(values, callback) {
chrome.storage.sync.set(values, callback)
},
onChanged: function(callback) {
chrome.storage.onChanged.addListener(function(changes, namespace) {
callback(changes)
})
},
forEachCurrent: function(callback) {
configuration.get(function (config) {
for (var prop in config) {
callback(prop, config[prop])
}
})
}
}
window.configuration = configuration
})()