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');
|
const btnClearSelection = document.getElementById('btn-clear-selection');
|
||||||
|
|
||||||
if (btnDownloadSelected) {
|
if (btnDownloadSelected) {
|
||||||
btnDownloadSelected.addEventListener('click', () => {
|
btnDownloadSelected.addEventListener('click', (e) => {
|
||||||
console.log('🎯 Click: Descargar Seleccionados');
|
console.log('🎯 BUTTON CLICKED: Descargar Seleccionados');
|
||||||
// Enviar mensaje al popup.js para ejecutar la descarga
|
console.log('📊 selectedMangas Set contents:', selectedMangas);
|
||||||
chrome.runtime.sendMessage({ action: 'triggerDownloadSelected' });
|
console.log('📊 selectedMangas size:', selectedMangas.size);
|
||||||
|
downloadSelectedMangas();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.error('❌ btnDownloadSelected not found!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnDownloadAll) {
|
if (btnDownloadAll) {
|
||||||
btnDownloadAll.addEventListener('click', () => {
|
btnDownloadAll.addEventListener('click', (e) => {
|
||||||
console.log('🎯 Click: Descargar TODOS');
|
console.log('🎯 BUTTON CLICKED: Descargar TODOS');
|
||||||
chrome.runtime.sendMessage({ action: 'triggerDownloadAll' });
|
downloadAllMangas();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.error('❌ btnDownloadAll not found!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnClearSelection) {
|
if (btnClearSelection) {
|
||||||
btnClearSelection.addEventListener('click', () => {
|
btnClearSelection.addEventListener('click', (e) => {
|
||||||
console.log('🎯 Click: Limpiar Selección');
|
console.log('🎯 BUTTON CLICKED: Limpiar Selección');
|
||||||
selectedMangas.clear();
|
selectedMangas.clear();
|
||||||
updateSelectedCount();
|
updateSelectedCount();
|
||||||
const countEl = document.getElementById('selected-count');
|
const countEl = document.getElementById('selected-count');
|
||||||
if (countEl) countEl.textContent = '0';
|
if (countEl) countEl.textContent = '0';
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.error('❌ btnClearSelection not found!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar contador inicialmente
|
// Actualizar contador inicialmente
|
||||||
@@ -590,22 +597,31 @@
|
|||||||
|
|
||||||
// Descargar manga seleccionados
|
// Descargar manga seleccionados
|
||||||
async function downloadSelectedMangas() {
|
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 = [];
|
const selectedObjects = [];
|
||||||
selectedMangas.forEach(id => {
|
selectedMangas.forEach(id => {
|
||||||
const mangaObj = mangaMetadata.get(id);
|
const mangaObj = mangaMetadata.get(id);
|
||||||
|
console.log(`📝 Checking ID ${id}:`, mangaObj);
|
||||||
if (mangaObj) {
|
if (mangaObj) {
|
||||||
selectedObjects.push(mangaObj);
|
selectedObjects.push(mangaObj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`📦 Final selectedObjects array length: ${selectedObjects.length}`);
|
||||||
|
console.log('📦 selectedObjects contents:', selectedObjects);
|
||||||
|
|
||||||
if (selectedObjects.length === 0) {
|
if (selectedObjects.length === 0) {
|
||||||
|
console.log('❌ No manga selected, showing alert');
|
||||||
alert('No hay manga seleccionados. Selecciona algunos manga primero.');
|
alert('No hay manga seleccionados. Selecciona algunos manga primero.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`📦 Manga seleccionados: ${selectedObjects.length}`);
|
console.log(`✅ Proceeding with download of ${selectedObjects.length} manga...`);
|
||||||
|
|
||||||
// Descargar cada manga
|
// Descargar cada manga
|
||||||
for (let i = 0; i < selectedObjects.length; i++) {
|
for (let i = 0; i < selectedObjects.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user