blob: 658f6952e99d84725d25f889e16598198efac6fa [file] [log] [blame]
avm99963cbea3142019-03-28 00:48:15 +01001function isEmpty(obj) {
2 return Object.keys(obj).length === 0;
3}
4
avm99963122dc9b2019-03-30 18:44:18 +01005var defaultOptions = {
6 "list": true,
7 "thread": true,
avm999636d9c5fe2019-06-04 00:35:53 +02008 "threadall": false,
avm99963122dc9b2019-03-30 18:44:18 +01009 "fixedtoolbar": false,
10 "redirect": false,
avm999636d9c5fe2019-06-04 00:35:53 +020011 "history": false,
avm99963af7860e2019-06-04 03:33:26 +020012 "loaddrafts": false,
avm99963c19497f2019-08-23 00:15:11 +020013 "batchduplicate": false,
14 "escalatethreads": false
avm99963122dc9b2019-03-30 18:44:18 +010015};
16
17function cleanUpOptions() {
18 chrome.storage.sync.get(null, function(options) {
avm999630a2840d2019-03-30 22:00:24 +010019 console.log("[cleanUpOptions] Previous options", options);
avm99963122dc9b2019-03-30 18:44:18 +010020 var ok = true;
21 for (const [opt, value] of Object.entries(defaultOptions)) {
avm999630a2840d2019-03-30 22:00:24 +010022 if (!(opt in options)) {
avm99963122dc9b2019-03-30 18:44:18 +010023 ok = false;
24 options[opt] = value;
25 }
26 }
27
avm999630a2840d2019-03-30 22:00:24 +010028 console.log("[cleanUpOptions] New options", options);
29
avm99963122dc9b2019-03-30 18:44:18 +010030 if (!ok) {
31 chrome.storage.sync.set(options);
avm99963cbea3142019-03-28 00:48:15 +010032 }
33 });
avm99963122dc9b2019-03-30 18:44:18 +010034}
35
36chrome.runtime.onInstalled.addListener(function(details) {
avm999630a2840d2019-03-30 22:00:24 +010037 if (details.reason == "install" || details.reason == "update") {
avm99963122dc9b2019-03-30 18:44:18 +010038 cleanUpOptions();
39 }
avm99963cbea3142019-03-28 00:48:15 +010040});