avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 1 | function isEmpty(obj) { |
| 2 | return Object.keys(obj).length === 0; |
| 3 | } |
| 4 | |
avm99963 | 122dc9b | 2019-03-30 18:44:18 +0100 | [diff] [blame^] | 5 | var defaultOptions = { |
| 6 | "list": true, |
| 7 | "thread": true, |
| 8 | "fixedtoolbar": false, |
| 9 | "redirect": false, |
| 10 | "history": false |
| 11 | }; |
| 12 | |
| 13 | function cleanUpOptions() { |
| 14 | chrome.storage.sync.get(null, function(options) { |
| 15 | var ok = true; |
| 16 | for (const [opt, value] of Object.entries(defaultOptions)) { |
| 17 | if (!opt in options) { |
| 18 | ok = false; |
| 19 | options[opt] = value; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | if (!ok) { |
| 24 | chrome.storage.sync.set(options); |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 25 | } |
| 26 | }); |
avm99963 | 122dc9b | 2019-03-30 18:44:18 +0100 | [diff] [blame^] | 27 | } |
| 28 | |
| 29 | chrome.runtime.onInstalled.addListener(function(details) { |
| 30 | if (details == "install" || details == "update") { |
| 31 | cleanUpOptions(); |
| 32 | } |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 33 | }); |