summaryrefslogtreecommitdiff
path: root/src/common/Storage.js
diff options
context:
space:
mode:
authorhackademix2018-07-01 01:01:23 +0200
committerhackademix2018-07-01 01:01:23 +0200
commiteceae7187a6f0e9510bc1165f6977256b87f490f (patch)
treed943f1ec73c09efa70954dcedb55eac82a726148 /src/common/Storage.js
downloadnoscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.gz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.tar.xz
noscript-eceae7187a6f0e9510bc1165f6977256b87f490f.zip
Initial commit starting at version 10.1.8.3rc4.
Diffstat (limited to 'src/common/Storage.js')
-rw-r--r--src/common/Storage.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/common/Storage.js b/src/common/Storage.js
new file mode 100644
index 0000000..4555a28
--- /dev/null
+++ b/src/common/Storage.js
@@ -0,0 +1,24 @@
+var Storage = {
+
+ async safeOp(op, type, keys) {
+ try {
+ return await browser.storage[type][op](keys);
+ } catch (e) {
+ if (type === "sync") {
+ debug("Sync disabled? Falling back to local storage (%s %o)", op, keys);
+ } else {
+ error(e);
+ throw e;
+ }
+ }
+ return await browser.storage.local[op](keys);
+ },
+
+ async get(type, keys) {
+ return await this.safeOp("get", type, keys);
+ },
+
+ async set(type, keys) {
+ return await this.safeOp("set", type, keys);
+ }
+}