login fix

This commit is contained in:
Basilosaurusrex
2026-03-02 11:59:29 +01:00
parent a1201d572e
commit a29086173f
10 changed files with 214 additions and 230 deletions

View File

@@ -53,7 +53,8 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// eBay Parsing Response (from eBay content script)
if (msg?.action === "PARSE_COMPLETE") {
handleParseComplete(sender.tab?.id, msg.data);
const tabId = sender?.tab?.id;
handleParseComplete(tabId, msg.data);
return true;
}
});
@@ -100,7 +101,10 @@ async function handleParseRequest(url, sendResponse) {
url: url,
active: false
});
if (!tab?.id) {
sendResponse({ ok: false, error: "Tab could not be created" });
return;
}
const tabId = tab.id;
console.log("[BACKGROUND] Tab created:", tabId);
@@ -330,6 +334,7 @@ function handleParseComplete(tabId, data) {
* Cleans up parse request: closes tab, clears timeout, sends response
*/
async function cleanupParseRequest(tabId, data, error) {
if (tabId == null) return;
const request = activeParseRequests.get(tabId);
if (!request) return;
@@ -410,7 +415,10 @@ async function handleScanProductsRequest(url, accountId, sendResponse) {
url: targetUrl,
active: false
});
if (!tab?.id) {
sendResponse({ ok: false, error: "Tab could not be created" });
return;
}
const tabId = tab.id;
// Set up timeout
@@ -562,7 +570,10 @@ async function loadAndParseEachItemTab(items) {
url: item.url,
active: false
});
if (!tab?.id) {
console.warn(`[BACKGROUND] Tab could not be created for item ${i + 1}, skipping`);
continue;
}
await new Promise((resolve) => {
const listener = (tabId, changeInfo) => {
if (tabId === tab.id && changeInfo.status === "complete") {
@@ -647,6 +658,7 @@ async function handleScanComplete(tabId, data) {
* Cleans up scan request: closes tab, clears timeout, sends response
*/
async function cleanupScanRequest(tabId, data, error) {
if (tabId == null) return;
const request = activeScanRequests.get(tabId);
if (!request) return;
@@ -751,7 +763,9 @@ async function handleParseAccountExtendedRequest(url, sendResponse) {
url: url,
active: false
});
if (!baseTab?.id) {
throw new Error("Tab could not be created");
}
await new Promise((resolve) => {
const checkLoaded = (tabId, changeInfo) => {
if (tabId === baseTab.id && changeInfo.status === 'complete') {
@@ -849,6 +863,10 @@ async function parseSingleTab(url, action, timeoutMs) {
url: url,
active: false
});
if (!tab?.id) {
reject(new Error("Tab could not be created"));
return;
}
tabId = tab.id;
// Set up timeout