Add a menu item to open the next link in a new tab.
This commit is contained in:
parent
13cd59bbe0
commit
b2d92796a9
|
@ -102,17 +102,31 @@ const contextMenus: Menus.CreateCreatePropertiesType[] = [
|
|||
id: 'queue-add-new-link-tab',
|
||||
title: 'Add to Queue',
|
||||
contexts: ['tab']
|
||||
},
|
||||
{
|
||||
id: 'queue-open-next-link-in-new-tab',
|
||||
title: 'Open next link in new tab',
|
||||
contexts: ['browser_action']
|
||||
}
|
||||
];
|
||||
|
||||
const contextMenuIDs: Set<string> = new Set(
|
||||
contextMenus.map((value) => value.id!)
|
||||
);
|
||||
|
||||
for (const menu of contextMenus) {
|
||||
browser.contextMenus.create(menu, contextCreated);
|
||||
}
|
||||
|
||||
browser.contextMenus.onClicked.addListener(async (info, _tab) => {
|
||||
if (info.menuItemId.toString().includes('queue-add-new-link')) {
|
||||
const settings = await getSettings();
|
||||
const id = info.menuItemId.toString();
|
||||
if (!contextMenuIDs.has(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = await getSettings();
|
||||
|
||||
if (id.includes('queue-add-new-link')) {
|
||||
let url: string;
|
||||
if (info.menuItemId === 'queue-add-new-link') {
|
||||
url = info.linkUrl!;
|
||||
|
@ -132,5 +146,13 @@ browser.contextMenus.onClicked.addListener(async (info, _tab) => {
|
|||
|
||||
await saveSettings(settings);
|
||||
await updateBadge(settings);
|
||||
} else if (id === 'queue-open-next-link-in-new-tab') {
|
||||
const nextItem = await getNextQItem(settings);
|
||||
if (nextItem === undefined) {
|
||||
await openOptionsPage();
|
||||
} else {
|
||||
await browser.tabs.create({active: true, url: nextItem.url});
|
||||
await removeQItem(nextItem.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -47,7 +47,14 @@ export function PageMain(props: MainProps): QComponent {
|
|||
|
||||
<p>Opening the next link from your queue:</p>
|
||||
<ul>
|
||||
<li>Click on the extension icon.</li>
|
||||
<li>
|
||||
Click on the extension icon to open it in the current tab (when
|
||||
possible).
|
||||
</li>
|
||||
<li>
|
||||
Right-click the extension icon and click "Open next link in new
|
||||
tab".
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>Opening the extension page:</p>
|
||||
|
|
Loading…
Reference in New Issue