From e8716657e43c46a97d80783593a8f90786a24558 Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 28 Aug 2018 01:23:27 +0200 Subject: Reordered startup sequence to be more friendly with embedders like the Tor Browser. --- src/bg/defaults.js | 60 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'src/bg/defaults.js') diff --git a/src/bg/defaults.js b/src/bg/defaults.js index 4d071b4..7170743 100644 --- a/src/bg/defaults.js +++ b/src/bg/defaults.js @@ -1,36 +1,38 @@ '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)); +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]); + 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; } - v.storage = k; - } - Object.assign(ns, defaults); + Object.assign(ns, defaults); - // dynamic settings - if (!ns.local.uuid) { - ns.local.uuid = uuid(); - await ns.save(ns.local); - } + // dynamic settings + if (!ns.local.uuid) { + ns.local.uuid = uuid(); + await ns.save(ns.local); + } - return ns.defaults = defaultsClone; -})(); + return ns.defaults = defaultsClone; + } +}; -- cgit v1.2.3