Skip to content

Commit

Permalink
fix: setting default values and handle manifest error
Browse files Browse the repository at this point in the history
  • Loading branch information
strumswell committed Dec 7, 2022
1 parent 0a06b76 commit 6f0501a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Shared (Extension)/Resources/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
// Retrieve action for settings change
} else if (request.type === "GetStoreExecution"){
browser.storage.local.get(request.id).then((res) => {
sendResponse({ checked: res[request.id] })
if(Object.keys(res).length > 0) {
sendResponse({ checked: res[request.id] })
} else {
// Set default value if not initialized yet
browser.storage.local.set({[request.id]: true})
sendResponse({ checked: true })
}
})
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions Shared (Extension)/Resources/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"1024": "images/1024.png"
},
"background": {
"service_worker": "background.js"
"scripts": ["background.js"]
},

"content_scripts": [{
"js": [ "content.js" ],
"matches": [ "https://*.twitch.tv/*" ]
Expand Down

0 comments on commit 6f0501a

Please sign in to comment.