diff --git a/bg.js b/bg.js index 4a82545..61ae8ed 100644 --- a/bg.js +++ b/bg.js @@ -1,12 +1,13 @@ browser.runtime.onInstalled.addListener((ev) => { if (ev.reason == "update") { + initialiseSettings(); updateIsSignificant(ev.previousVersion).then( v => { if (v) launchInfoPage(); } ) } else if (ev.reason == "install") { - browser.runtime.openOptionsPage() + initialiseSettings().then(() => browser.runtime.openOptionsPage()); } }) @@ -17,4 +18,11 @@ async function updateIsSignificant(previousVersion) { } function launchInfoPage(){ browser.tabs.create({url: "/changelog.htm", active: false}) -} \ No newline at end of file +} + +async function initialiseSettings(){ + let defaultSettings = {"enable": true, "showChangelog": true}; + const presentSettings = await browser.storage.sync.get(); + defaultSettings = Object.fromEntries(Object.entries(defaultSettings).filter((k, v) => !(k in presentSettings))); + await browser.storage.sync.set(defaultSettings); +} \ No newline at end of file