-
Notifications
You must be signed in to change notification settings - Fork 12
/
devtools-redirect.js
52 lines (40 loc) · 1.18 KB
/
devtools-redirect.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
(function(window) {
window.DevtoolsRedirect = {
//Constants,
//Vars,
options: {},
storageItems: null,
storageOptions: null,
//Functions,
init: function(options) {
this.options = $.extend(true, this.options, options);
this.storageItems = $.merge([], ['rules'], this.options.storageOptions);
//We'll use the chrome storage API,
if(chrome.storage) this.storage = chrome.storage.sync;
//Make sure we have storage,
if(!this.storage) throw(new Error("No storage defined"));
},
getOptions: function(opts) {
var def = new $.Deferred();
this.storage.get(opts ? opts : this.options.storageOptions, function(items) { def.resolve(items); });
return def;
},
/*
setOptions()
- params: opts -> {'option_name': theOptionValue}
*/
setOption: function(opt) {
var def = new $.Deferred();
this.storage.set(opt, function() { def.resolve(); });
return def;
}
};
//Init DevtoolsRedirect w/ default store options,
DevtoolsRedirect.init({
storageOptions: [
'root',
'disabled',
'rules'
]
});
})(window);