diff --git a/background.js b/background.js index 0a0502d..cf5ff1f 100644 --- a/background.js +++ b/background.js @@ -1,23 +1,37 @@ const TABS = {}; -function clickHandler(tab) { - browser.tabs.create({ - url: TABS[tab.id][0].href - }); +async function clickHandler(tab) { + const opts = await browser.storage.local.get('openFeed'); + if (opts.hasOwnProperty('openFeed')) { + switch (opts.openFeed) { + case 'window': + browser.windows.create({url: TABS[tab.id][0].href}); + break; + case 'tab': + browser.tabs.create({url: TABS[tab.id][0].href}); + break; + case 'current': + browser.tabs.update(null, {url: TABS[tab.id][0].href}); + break; + default: + throw new Error(`Unsupported open feed method: ${opts.openFeed}`); + } + } else { + browser.tabs.update(null, {url: TABS[tab.id][0].href}); + } } function removeHandler(tabId) { delete TABS[tabId]; } -function updatePageAction(tab, links) { +async function updatePageAction(tab, links) { if (links.length > 0) { TABS[tab.id] = links; - browser.storage.local.get('icon').then(icon => { - browser.pageAction.setIcon({ - tabId: tab.id, - path: icon.icon || 'icons/subscribe-16.svg' - }); + const opts = await browser.storage.local.get('icon'); + browser.pageAction.setIcon({ + tabId: tab.id, + path: opts.icon || 'icons/subscribe-16.svg' }); browser.pageAction.show(tab.id); } @@ -50,10 +64,10 @@ function scanPage(tab) { } } -function refreshAllTabsPageAction() { - browser.tabs.query({}).then(tabs => tabs.forEach(scanPage)).catch(console.error); +async function refreshAllTabsPageAction() { + const tabs = await browser.tabs.query({}); + tabs.forEach(scanPage); } - browser.runtime.onMessage.addListener(messageHandler); browser.tabs.onRemoved.addListener(removeHandler); browser.tabs.onUpdated.addListener(scanPage); diff --git a/manifest.json b/manifest.json index 1c22d37..c8b518c 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "name": "Chris Zuber", "url": "https://chriszuber.com" }, - "version": "0.4.0", + "version": "0.4.1", "description": "__MSG_extensionDescription__", "homepage_url": "https://github.com/shgysk8zer0/awesome-rss", "icons": { diff --git a/options.html b/options.html index 5656328..053b1c4 100644 --- a/options.html +++ b/options.html @@ -17,11 +17,15 @@ - + + +