Skip to content

Commit

Permalink
fix ff erros
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanb10 committed Jun 27, 2021
1 parent 1c3deac commit 85c0569
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Roadmap
*In no particular order*
- Snooze again + recurring snoozes
- Recurring snoozes
- Cloud sync
- Make contextMenu + allTabs permissions optional
- Make accessibile
Expand Down
17 changes: 9 additions & 8 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: ['<all_urls>'],
...(getBrowser() === 'firefox') ? {icons: {32: `../icons/${cm[0]}.png`}} : {}
})
});
} else {
chrome.contextMenus.create({id: 'snoozz', contexts: contexts, title: 'Snoozz', documentUrlPatterns: ['<all_urls>']})
cm.forEach(o => chrome.contextMenus.create({
await chrome.contextMenus.removeAll();
await chrome.contextMenus.create({id: 'snoozz', contexts: contexts, title: 'Snoozz', documentUrlPatterns: ['<all_urls>']})
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');
Expand Down
2 changes: 1 addition & 1 deletion scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 85c0569

Please sign in to comment.