summaryrefslogtreecommitdiff
path: root/src/bg/Defaults.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bg/Defaults.js')
-rw-r--r--src/bg/Defaults.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/bg/Defaults.js b/src/bg/Defaults.js
new file mode 100644
index 0000000..ef2311f
--- /dev/null
+++ b/src/bg/Defaults.js
@@ -0,0 +1,38 @@
+'use strict';
+
+var Defaults = {
+ async init() {
+ let defaults = {
+ local: {
+ debug: false,
+ showCtxMenuItem: true,
+ showCountBadge: true,
+ showFullAddresses: false,
+ },
+ sync: {
+ "global": false,
+ "xss": true,
+ "clearclick": true
+ }
+ };
+ let defaultsClone = JSON.parse(JSON.stringify(defaults));
+
+ for (let [k, v] of Object.entries(defaults)) {
+ let store = await Storage.get(k, k);
+ if (k in store) {
+ Object.assign(v, store[k]);
+ }
+ v.storage = k;
+ }
+
+ Object.assign(ns, defaults);
+
+ // dynamic settings
+ if (!ns.local.uuid) {
+ ns.local.uuid = uuid();
+ await ns.save(ns.local);
+ }
+
+ return ns.defaults = defaultsClone;
+ }
+};