Use the tab title when adding from tab menu.

This commit is contained in:
Bauke 2020-11-20 18:55:20 +01:00
parent 4aef9cae6e
commit 792bd26d4f
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 6 additions and 3 deletions

View File

@ -123,7 +123,7 @@ for (const menu of contextMenus) {
browser.contextMenus.create(menu, contextCreated);
}
browser.contextMenus.onClicked.addListener(async (info, _tab) => {
browser.contextMenus.onClicked.addListener(async (info, tab) => {
const id = info.menuItemId.toString();
if (!contextMenuIDs.has(id)) {
return;
@ -132,10 +132,13 @@ browser.contextMenus.onClicked.addListener(async (info, _tab) => {
const settings = await getSettings();
if (id.includes('queue-add-new-link')) {
let text: string | undefined;
let url: string;
if (info.menuItemId === 'queue-add-new-link') {
text = info.linkText;
url = info.linkUrl!;
} else if (info.menuItemId === 'queue-add-new-link-tab') {
text = tab?.title;
url = info.pageUrl!;
} else {
error(`Unknown menuItemId: ${info.menuItemId}`);
@ -145,7 +148,7 @@ browser.contextMenus.onClicked.addListener(async (info, _tab) => {
settings.queue.push({
added: new Date(),
id: newQItemID(settings.queue),
text: info.linkText ?? url,
text: text ?? url,
url
});

View File

@ -3,7 +3,7 @@
"manifest_version": 2,
"name": "Queue",
"description": "A WebExtension for queueing links.",
"version": "0.1.5",
"version": "0.1.6",
"permissions": [
"contextMenus",
"storage",