Add message listener logging
🔍 Now logs ALL messages received from popup.js:
- Logs when any message is received (with action type)
- Logs showProgress messages specifically
- Logs getSelectedMangas requests
- Logs getImageUrls requests
- Logs extractAllMangas requests
- Logs hideProgress requests
This will tell us if popup.js is actually sending messages to content script
This commit is contained in:
16
content.js
16
content.js
@@ -135,6 +135,8 @@
|
|||||||
|
|
||||||
// Escuchar mensajes del popup
|
// Escuchar mensajes del popup
|
||||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||||
|
console.log('📨 MENSAJE RECIBIDO:', request.action, request);
|
||||||
|
|
||||||
if (request.action === 'getSelectedMangas') {
|
if (request.action === 'getSelectedMangas') {
|
||||||
// Devolver objetos completos en lugar de solo IDs
|
// Devolver objetos completos en lugar de solo IDs
|
||||||
const selectedObjects = [];
|
const selectedObjects = [];
|
||||||
@@ -144,25 +146,32 @@
|
|||||||
selectedObjects.push(mangaObj);
|
selectedObjects.push(mangaObj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('📤 Enviando mangas seleccionados:', selectedObjects.length);
|
||||||
sendResponse({ mangas: selectedObjects });
|
sendResponse({ mangas: selectedObjects });
|
||||||
} else if (request.action === 'clearSelection') {
|
} else if (request.action === 'clearSelection') {
|
||||||
selectedMangas.clear();
|
selectedMangas.clear();
|
||||||
updateSelectedCount();
|
updateSelectedCount();
|
||||||
sendResponse({ success: true });
|
sendResponse({ success: true });
|
||||||
} else if (request.action === 'getImageUrls') {
|
} else if (request.action === 'getImageUrls') {
|
||||||
|
console.log('📸 Solicitando URLs de imágenes para:', request.manga.title);
|
||||||
getImageUrlsForManga(request.manga)
|
getImageUrlsForManga(request.manga)
|
||||||
.then(imageUrls => sendResponse({ imageUrls }))
|
.then(imageUrls => sendResponse({ imageUrls }))
|
||||||
.catch(error => sendResponse({ error: error.message }));
|
.catch(error => sendResponse({ error: error.message }));
|
||||||
return true;
|
return true;
|
||||||
} else if (request.action === 'extractAllMangas') {
|
} else if (request.action === 'extractAllMangas') {
|
||||||
const allMangas = extractAllMangasFromPage();
|
const allMangas = extractAllMangasFromPage();
|
||||||
|
console.log('📤 Enviando todos los mangas:', allMangas.length);
|
||||||
sendResponse({ mangas: allMangas });
|
sendResponse({ mangas: allMangas });
|
||||||
} else if (request.action === 'showProgress') {
|
} else if (request.action === 'showProgress') {
|
||||||
|
console.log('📊 Mostrando progreso:', request);
|
||||||
updateProgress(request.current, request.total, request.title, request.status);
|
updateProgress(request.current, request.total, request.title, request.status);
|
||||||
sendResponse({ success: true });
|
sendResponse({ success: true });
|
||||||
} else if (request.action === 'hideProgress') {
|
} else if (request.action === 'hideProgress') {
|
||||||
|
console.log('🙈 Ocultando progreso');
|
||||||
hideProgress();
|
hideProgress();
|
||||||
sendResponse({ success: true });
|
sendResponse({ success: true });
|
||||||
|
} else {
|
||||||
|
console.log('❓ Acción desconocida:', request.action);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -491,6 +500,13 @@
|
|||||||
addCheckboxes();
|
addCheckboxes();
|
||||||
addSelectAllButton();
|
addSelectAllButton();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
// TEST: Crear popup de prueba para verificar que funciona
|
||||||
|
console.log('🧪 Creando popup de prueba...');
|
||||||
|
setTimeout(() => {
|
||||||
|
updateProgress(1, 5, 'Prueba', 'Verificando si el popup funciona');
|
||||||
|
console.log('✅ Popup de prueba enviado');
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
|
|||||||
Reference in New Issue
Block a user