fix(collect): include relative links under /download and add fallback collection path

- Content script: base href check via absolute URL; scope to listing container
- Popup: fallback to background-assisted collection when no receiver exists
- Background: expose collect.fromTab to run injection + collection
- Add debug logging for visibility
This commit is contained in:
Jordan Wages 2025-08-22 00:29:48 -05:00
commit 92ec0a9a74
3 changed files with 30 additions and 7 deletions

View file

@ -47,7 +47,15 @@ async function refresh() {
try {
const tabId = await getActiveTabId();
if (!tabId) throw new Error('No active tab');
const items = await browser.tabs.sendMessage(tabId, { type: 'collectLinks' });
let items = [];
try {
items = await browser.tabs.sendMessage(tabId, { type: 'collectLinks' });
} catch (e) {
// Fallback: ask background to inject and collect
const res = await browser.runtime.sendMessage({ type: 'collect.fromTab', tabId });
if (res?.ok) items = res.items || [];
else throw new Error(res?.error || e?.message || 'collect failed');
}
allItems = items || [];
updateCount();
} catch (e) {