blob: 14cda5a36a6b55215846cc95206fd0363e71b854 [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,
avm99963eb2d0b82019-10-07 22:58:55 +020014 "escalatethreads": false,
15 "movethreads": false
avm99963122dc9b2019-03-30 18:44:18 +010016};
17
18function cleanUpOptions() {
19 chrome.storage.sync.get(null, function(options) {
avm999630a2840d2019-03-30 22:00:24 +010020 console.log("[cleanUpOptions] Previous options", options);
avm99963122dc9b2019-03-30 18:44:18 +010021 var ok = true;
22 for (const [opt, value] of Object.entries(defaultOptions)) {
avm999630a2840d2019-03-30 22:00:24 +010023 if (!(opt in options)) {
avm99963122dc9b2019-03-30 18:44:18 +010024 ok = false;
25 options[opt] = value;
26 }
27 }
28
avm999630a2840d2019-03-30 22:00:24 +010029 console.log("[cleanUpOptions] New options", options);
30
avm99963122dc9b2019-03-30 18:44:18 +010031 if (!ok) {
32 chrome.storage.sync.set(options);
avm99963cbea3142019-03-28 00:48:15 +010033 }
34 });
avm99963122dc9b2019-03-30 18:44:18 +010035}
36
37chrome.runtime.onInstalled.addListener(function(details) {
avm999630a2840d2019-03-30 22:00:24 +010038 if (details.reason == "install" || details.reason == "update") {
avm99963122dc9b2019-03-30 18:44:18 +010039 cleanUpOptions();
40 }
avm99963cbea3142019-03-28 00:48:15 +010041});