diff options
author | hackademix | 2018-09-15 22:10:19 +0200 |
---|---|---|
committer | hackademix | 2018-09-15 22:11:31 +0200 |
commit | e4e1c83f2cac33341d9ad132dea8ca90c15487a4 (patch) | |
tree | b4848028cb557c4f5f1e2cef8d5ee99697b74cb0 /src/bg/Defaults.js | |
parent | 297fec781f1b49c6dd06578139742d4e841cc433 (diff) | |
download | noscript-e4e1c83f2cac33341d9ad132dea8ca90c15487a4.tar.gz noscript-e4e1c83f2cac33341d9ad132dea8ca90c15487a4.tar.xz noscript-e4e1c83f2cac33341d9ad132dea8ca90c15487a4.zip |
Fixed line endings.
Diffstat (limited to 'src/bg/Defaults.js')
-rw-r--r-- | src/bg/Defaults.js | 38 |
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;
+ }
+};
|