Add comprehensive button click debugging
🔍 Now logs:
- Button click events
- Function execution
- selectedMangas Set contents and size
- mangaMetadata Map size
- Each metadata lookup
- Final selectedObjects array
- Button element existence check
This will show us exactly where the chain is breaking!
This commit is contained in:
38
content.js
38
content.js
@@ -75,28 +75,35 @@
|
||||
const btnClearSelection = document.getElementById('btn-clear-selection');
|
||||
|
||||
if (btnDownloadSelected) {
|
||||
btnDownloadSelected.addEventListener('click', () => {
|
||||
console.log('🎯 Click: Descargar Seleccionados');
|
||||
// Enviar mensaje al popup.js para ejecutar la descarga
|
||||
chrome.runtime.sendMessage({ action: 'triggerDownloadSelected' });
|
||||
btnDownloadSelected.addEventListener('click', (e) => {
|
||||
console.log('🎯 BUTTON CLICKED: Descargar Seleccionados');
|
||||
console.log('📊 selectedMangas Set contents:', selectedMangas);
|
||||
console.log('📊 selectedMangas size:', selectedMangas.size);
|
||||
downloadSelectedMangas();
|
||||
});
|
||||
} else {
|
||||
console.error('❌ btnDownloadSelected not found!');
|
||||
}
|
||||
|
||||
if (btnDownloadAll) {
|
||||
btnDownloadAll.addEventListener('click', () => {
|
||||
console.log('🎯 Click: Descargar TODOS');
|
||||
chrome.runtime.sendMessage({ action: 'triggerDownloadAll' });
|
||||
btnDownloadAll.addEventListener('click', (e) => {
|
||||
console.log('🎯 BUTTON CLICKED: Descargar TODOS');
|
||||
downloadAllMangas();
|
||||
});
|
||||
} else {
|
||||
console.error('❌ btnDownloadAll not found!');
|
||||
}
|
||||
|
||||
if (btnClearSelection) {
|
||||
btnClearSelection.addEventListener('click', () => {
|
||||
console.log('🎯 Click: Limpiar Selección');
|
||||
btnClearSelection.addEventListener('click', (e) => {
|
||||
console.log('🎯 BUTTON CLICKED: Limpiar Selección');
|
||||
selectedMangas.clear();
|
||||
updateSelectedCount();
|
||||
const countEl = document.getElementById('selected-count');
|
||||
if (countEl) countEl.textContent = '0';
|
||||
});
|
||||
} else {
|
||||
console.error('❌ btnClearSelection not found!');
|
||||
}
|
||||
|
||||
// Actualizar contador inicialmente
|
||||
@@ -590,22 +597,31 @@
|
||||
|
||||
// Descargar manga seleccionados
|
||||
async function downloadSelectedMangas() {
|
||||
console.log('📥 Iniciando descarga de manga seleccionados...');
|
||||
console.log('\n========== 🔥 DOWNLOAD SELECTED MANGAS STARTED ==========');
|
||||
console.log('🔍 Function called!');
|
||||
console.log('📊 selectedMangas Set:', selectedMangas);
|
||||
console.log('📊 selectedMangas size:', selectedMangas.size);
|
||||
console.log('📊 mangaMetadata Map size:', mangaMetadata.size);
|
||||
|
||||
const selectedObjects = [];
|
||||
selectedMangas.forEach(id => {
|
||||
const mangaObj = mangaMetadata.get(id);
|
||||
console.log(`📝 Checking ID ${id}:`, mangaObj);
|
||||
if (mangaObj) {
|
||||
selectedObjects.push(mangaObj);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`📦 Final selectedObjects array length: ${selectedObjects.length}`);
|
||||
console.log('📦 selectedObjects contents:', selectedObjects);
|
||||
|
||||
if (selectedObjects.length === 0) {
|
||||
console.log('❌ No manga selected, showing alert');
|
||||
alert('No hay manga seleccionados. Selecciona algunos manga primero.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`📦 Manga seleccionados: ${selectedObjects.length}`);
|
||||
console.log(`✅ Proceeding with download of ${selectedObjects.length} manga...`);
|
||||
|
||||
// Descargar cada manga
|
||||
for (let i = 0; i < selectedObjects.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user