diff options
Diffstat (limited to 'src/bg/defaults.js')
-rw-r--r-- | src/bg/defaults.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/bg/defaults.js b/src/bg/defaults.js new file mode 100644 index 0000000..220bd23 --- /dev/null +++ b/src/bg/defaults.js @@ -0,0 +1,37 @@ +'use strict'; + +ns.defaults = (async () => { + 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) { + await include("/lib/uuid.js"); + ns.local.uuid = uuid(); + await ns.save(ns.local); + } + + return ns.defaults = defaultsClone; +})(); |