Use the tab title when adding from tab menu.
This commit is contained in:
		
							parent
							
								
									4aef9cae6e
								
							
						
					
					
						commit
						792bd26d4f
					
				|  | @ -123,7 +123,7 @@ for (const menu of contextMenus) { | ||||||
|   browser.contextMenus.create(menu, contextCreated); |   browser.contextMenus.create(menu, contextCreated); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| browser.contextMenus.onClicked.addListener(async (info, _tab) => { | browser.contextMenus.onClicked.addListener(async (info, tab) => { | ||||||
|   const id = info.menuItemId.toString(); |   const id = info.menuItemId.toString(); | ||||||
|   if (!contextMenuIDs.has(id)) { |   if (!contextMenuIDs.has(id)) { | ||||||
|     return; |     return; | ||||||
|  | @ -132,10 +132,13 @@ browser.contextMenus.onClicked.addListener(async (info, _tab) => { | ||||||
|   const settings = await getSettings(); |   const settings = await getSettings(); | ||||||
| 
 | 
 | ||||||
|   if (id.includes('queue-add-new-link')) { |   if (id.includes('queue-add-new-link')) { | ||||||
|  |     let text: string | undefined; | ||||||
|     let url: string; |     let url: string; | ||||||
|     if (info.menuItemId === 'queue-add-new-link') { |     if (info.menuItemId === 'queue-add-new-link') { | ||||||
|  |       text = info.linkText; | ||||||
|       url = info.linkUrl!; |       url = info.linkUrl!; | ||||||
|     } else if (info.menuItemId === 'queue-add-new-link-tab') { |     } else if (info.menuItemId === 'queue-add-new-link-tab') { | ||||||
|  |       text = tab?.title; | ||||||
|       url = info.pageUrl!; |       url = info.pageUrl!; | ||||||
|     } else { |     } else { | ||||||
|       error(`Unknown menuItemId: ${info.menuItemId}`); |       error(`Unknown menuItemId: ${info.menuItemId}`); | ||||||
|  | @ -145,7 +148,7 @@ browser.contextMenus.onClicked.addListener(async (info, _tab) => { | ||||||
|     settings.queue.push({ |     settings.queue.push({ | ||||||
|       added: new Date(), |       added: new Date(), | ||||||
|       id: newQItemID(settings.queue), |       id: newQItemID(settings.queue), | ||||||
|       text: info.linkText ?? url, |       text: text ?? url, | ||||||
|       url |       url | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
|   "manifest_version": 2, |   "manifest_version": 2, | ||||||
|   "name": "Queue", |   "name": "Queue", | ||||||
|   "description": "A WebExtension for queueing links.", |   "description": "A WebExtension for queueing links.", | ||||||
|   "version": "0.1.5", |   "version": "0.1.6", | ||||||
|   "permissions": [ |   "permissions": [ | ||||||
|     "contextMenus", |     "contextMenus", | ||||||
|     "storage", |     "storage", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue