diff --git a/docs/changelog.md b/docs/changelog.md index 5eda56b..b612d6d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,6 @@ ## Roadmap *In no particular order* -- Snooze again + recurring snoozes +- Recurring snoozes - Cloud sync - Make contextMenu + allTabs permissions optional - Make accessibile diff --git a/scripts/background.js b/scripts/background.js index d28aeb4..3fb2428 100644 --- a/scripts/background.js +++ b/scripts/background.js @@ -82,31 +82,32 @@ async function wakeMeUp(tabs) { } async function setUpContextMenus(cachedMenus) { - await chrome.contextMenus.removeAll(); var cm = cachedMenus || await getOptions('contextMenu'); if (!cm || !cm.length || cm.length === 0) return; var choices = await getChoices(); var contexts = getBrowser() === 'firefox' ? ['link', 'tab'] : ['link']; if (cm.length === 1) { - chrome.contextMenus.create({ + await chrome.contextMenus.removeAll(); + await chrome.contextMenus.create({ id: cm[0], contexts: contexts, title: `Snoozz ${choices[cm[0]].label.toLowerCase()}`, documentUrlPatterns: [''], ...(getBrowser() === 'firefox') ? {icons: {32: `../icons/${cm[0]}.png`}} : {} - }) + }); } else { - chrome.contextMenus.create({id: 'snoozz', contexts: contexts, title: 'Snoozz', documentUrlPatterns: ['']}) - cm.forEach(o => chrome.contextMenus.create({ + await chrome.contextMenus.removeAll(); + await chrome.contextMenus.create({id: 'snoozz', contexts: contexts, title: 'Snoozz', documentUrlPatterns: ['']}) + for (var o of cm) await chrome.contextMenus.create({ parentId: 'snoozz', id: o, contexts: contexts, title: choices[o].menuLabel, ...(getBrowser() === 'firefox') ? {icons: {32: `../icons/${o}.png`}} : {} - })); + }); } - chrome.contextMenus.onClicked.addListener(snoozeInBackground) - if (getBrowser() === 'firefox') chrome.contextMenus.onShown.addListener(contextMenuUpdater) + chrome.contextMenus.onClicked.addListener(snoozeInBackground); + if (getBrowser() === 'firefox') chrome.contextMenus.onShown.addListener(contextMenuUpdater); } if (chrome.commands) chrome.commands.onCommand.addListener(async (command, tab) => { if (command === 'nap-room') return openExtensionTab('/html/nap-room.html'); diff --git a/scripts/common.js b/scripts/common.js index a0ee4a0..8132a80 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -85,7 +85,7 @@ async function createAlarm(when, willWakeUpATab) { async function createNotification(id, title, imgUrl, message, force) { var n = typeof SAVED_OPTIONS !== 'undefined' && SAVED_OPTIONS.notifications ? SAVED_OPTIONS.notifications : await getOptions('notifications'); if (!chrome.notifications || (n && n === 'off' && !force)) return; - await chrome.notifications.create(id, {type: 'basic', iconUrl: chrome.extension.getURL(imgUrl), title, message}); + await chrome.notifications.create(id, {type: 'basic', iconUrl: chrome.runtime.getURL(imgUrl), title, message}); } async function createWindow(tabId) { return new Promise(r => chrome.windows.create({url: `/html/rise-and-shine.html#${tabId}`}, r));