From e4e1c83f2cac33341d9ad132dea8ca90c15487a4 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sat, 15 Sep 2018 22:10:19 +0200 Subject: Fixed line endings. --- src/bg/Defaults.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/bg/Defaults.js (limited to 'src/bg/Defaults.js') 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; + } +}; -- cgit v1.2.3