From 1186566cc55a92366a0c3b809b434b711f345afd Mon Sep 17 00:00:00 2001 From: Ida <1715762+ida@users.noreply.github.com> Date: Thu, 25 Nov 2021 12:06:47 +0100 Subject: [PATCH] Fallback to default value, if localStorage.shortkeys does not exist, yet. Fixes #424 Note: Loading `app/manifest.json` in `about:debugging` doesn't throw the error, but loading `dist/firefox/manifest.json` does. --- app/scripts/background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index ba102a6..12fd8c8 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -379,7 +379,7 @@ browser.runtime.onMessage.addListener(function (request, sender, sendResponse) { const action = request.action if (action === 'getKeys') { const currentUrl = request.url - let settings = JSON.parse(localStorage.shortkeys) + let settings = localStorage.shortkeys ? JSON.parse(localStorage.shortkeys) : [{}] let keys = [] if (settings.keys.length > 0) { settings.keys.forEach((key) => { @@ -391,4 +391,4 @@ browser.runtime.onMessage.addListener(function (request, sender, sendResponse) { return Promise.resolve(keys) } handleAction(action, request) -}) \ No newline at end of file +})