forked from EFForg/https-everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
44 lines (37 loc) · 812 Bytes
/
store.js
File metadata and controls
44 lines (37 loc) · 812 Bytes
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
"use strict";
(function(exports) {
let ls;
try {
ls = localStorage;
} catch(e) {
ls = {setItem: () => {}, getItem: () => {}};
}
function initialize() {
return new Promise(resolve => {
if (chrome.storage.sync) {
chrome.storage.sync.set({"sync-set-test": true}, () => {
if(chrome.runtime.lastError){
setStorage(chrome.storage.local);
} else {
setStorage(chrome.storage.sync);
}
resolve();
});
} else {
setStorage(chrome.storage.local);
resolve();
}
});
}
function setStorage(store) {
Object.assign(exports, {
get: store.get,
set: store.set,
localStorage: ls,
initialize
});
}
Object.assign(exports, {
initialize
});
})(typeof exports == 'undefined' ? require.scopes.store = {} : exports);