Enhance eBay extension logging and account management features
- Added detailed logging for various actions in the background script and content script to improve debugging capabilities. - Updated the account management flow to include the last updated timestamp and sales data. - Refined the parsing logic to ensure accurate extraction of seller statistics from eBay profiles. - Improved error handling in the parsing process to provide more informative responses in case of failures.
This commit is contained in:
@@ -3,14 +3,64 @@
|
||||
* Wird auf eBay-Seiten ausgeführt und extrahiert Verkäufer-/Shop-Daten aus dem DOM
|
||||
*/
|
||||
|
||||
// Log dass Content Script geladen wurde
|
||||
console.log("[EBAY-CONTENT] Content script loaded on:", window.location.href);
|
||||
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebay-content-script.js:7',message:'ebay-content-script: loaded',data:{url:window.location.href,readyState:document.readyState},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
// Message Listener für Parsing-Anfragen
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebay-content-script.js:10',message:'ebay-content-script: message received',data:{action:message.action},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
// Ping-Handler für Content Script Verfügbarkeitsprüfung
|
||||
if (message.action === "PING") {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebay-content-script.js:13',message:'ebay-content-script: PING handler',data:{},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
||||
// #endregion
|
||||
sendResponse({ ok: true, ready: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (message.action === "PARSE_EBAY") {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'ebay-content-script.js:17',message:'ebay-content-script: PARSE_EBAY handler',data:{readyState:document.readyState},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
||||
// #endregion
|
||||
// Wrapper um sicherzustellen, dass immer eine Antwort gesendet wird
|
||||
try {
|
||||
// Prüfe ob DOM bereit ist
|
||||
if (document.readyState === 'loading') {
|
||||
// DOM noch nicht bereit, warte kurz
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
try {
|
||||
const parsedData = parseEbayPage();
|
||||
sendResponse({ ok: true, data: parsedData });
|
||||
} catch (error) {
|
||||
console.error("[EBAY-CONTENT] Error parsing:", error);
|
||||
sendResponse({
|
||||
ok: true,
|
||||
data: {
|
||||
sellerId: "",
|
||||
shopName: "",
|
||||
market: extractMarketFromHostname(),
|
||||
status: "unknown",
|
||||
stats: {}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, { once: true });
|
||||
return true; // async response
|
||||
}
|
||||
|
||||
// DOM ist bereit, parse sofort
|
||||
const parsedData = parseEbayPage();
|
||||
sendResponse({ ok: true, data: parsedData });
|
||||
} catch (error) {
|
||||
// Niemals unhandled throws - immer graceful response
|
||||
console.error("[EBAY-CONTENT] Error in parse handler:", error);
|
||||
sendResponse({
|
||||
ok: true,
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user