Skip to content

Commit 65790c0

Browse files
committed
Implementing Android Capture Fix
1 parent 38a7de2 commit 65790c0

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

background.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,20 @@ chrome.webRequest.onHeadersReceived.addListener(
298298
}
299299
}
300300

301-
// 5. Save to storage
302-
chrome.storage.local.get(['capturedMedia'], (stored) => {
303-
const freshMedia = stored.capturedMedia || [];
304-
// Re-check for duplicates just in case
305-
if (!freshMedia.find(m => m.url === mediaItem.url)) {
306-
freshMedia.unshift(mediaItem);
307-
if (freshMedia.length > 100) freshMedia.pop();
308-
capturedMedia = freshMedia;
309-
chrome.storage.local.set({ capturedMedia: freshMedia });
310-
if (mediaItem.downloadId) {
311-
addLog(`Media captured & download started: ${mediaItem.filename}`);
312-
} else {
313-
addLog(chrome.i18n.getMessage("log_intercepted", [mediaItem.filename]));
314-
}
301+
// 5. Update in-memory state immediately
302+
capturedMedia.unshift(mediaItem);
303+
if (capturedMedia.length > 100) {
304+
const removed = capturedMedia.pop();
305+
capturedUrls.delete(removed.url);
306+
}
307+
capturedUrls.add(mediaItem.url);
308+
309+
// 6. Save to storage reliably
310+
chrome.storage.local.set({ capturedMedia: capturedMedia }, () => {
311+
if (mediaItem.downloadId) {
312+
addLog(`Media captured & download started: ${mediaItem.filename}`);
313+
} else {
314+
addLog(chrome.i18n.getMessage("log_intercepted", [mediaItem.filename]));
315315
}
316316
});
317317
};

0 commit comments

Comments
 (0)