Add debug button to detect page counts

New button added:
- 🔍 Debug: Contar Páginas (purple button)
- Scans ALL manga on the page
- Fetches each manga's gallery page
- Detects page count using the same logic
- Shows detailed results in console
- Lists: Title, URL, and detected page count

Usage:
1. Click the purple 'Debug: Contar Páginas' button
2. Check console for detailed results
3. Share the console output

This will show exactly what page counts are being detected!
This commit is contained in:
renato97
2025-11-04 05:38:35 +00:00
parent 8cc0ba5534
commit 8f15cb8001

View File

@@ -51,6 +51,7 @@
<button id="btn-download-selected" style="width: 100%; padding: 10px; margin: 5px 0; background: #4CAF50; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold;">⬇️ Descargar Seleccionados</button>
<button id="btn-download-all" style="width: 100%; padding: 10px; margin: 5px 0; background: #2196F3; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold;">📚 Descargar TODOS</button>
<button id="btn-clear-selection" style="width: 100%; padding: 10px; margin: 5px 0; background: #ff9800; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold;">🗑️ Limpiar Selección</button>
<button id="btn-debug-pages" style="width: 100%; padding: 10px; margin: 5px 0; background: #9C27B0; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 11px;">🔍 Debug: Contar Páginas</button>
</div>
<!-- Panel de progreso (cuando está descargando) -->
@@ -73,6 +74,7 @@
const btnDownloadSelected = document.getElementById('btn-download-selected');
const btnDownloadAll = document.getElementById('btn-download-all');
const btnClearSelection = document.getElementById('btn-clear-selection');
const btnDebugPages = document.getElementById('btn-debug-pages');
if (btnDownloadSelected) {
btnDownloadSelected.addEventListener('click', (e) => {
@@ -106,6 +108,15 @@
console.error('❌ btnClearSelection not found!');
}
if (btnDebugPages) {
btnDebugPages.addEventListener('click', (e) => {
console.log('🎯 BUTTON CLICKED: Debug Contar Páginas');
debugCountPagesForAllManga();
});
} else {
console.error('❌ btnDebugPages not found!');
}
// Actualizar contador inicialmente
const countEl = document.getElementById('selected-count');
if (countEl) countEl.textContent = selectedMangas.size.toString();
@@ -760,6 +771,69 @@
}, 2000);
}
// Debug: Contar páginas para todos los manga en la página
async function debugCountPagesForAllManga() {
console.log('\n========== 🔍 DEBUG: PAGE COUNT DETECTION ==========');
console.log('🔍 Scanning all manga on page...');
const allMangas = extractAllMangasFromPage();
console.log(`📦 Found ${allMangas.length} manga on page`);
const results = [];
for (let i = 0; i < allMangas.length; i++) {
const manga = allMangas[i];
console.log(`\n--- 🔍 MANGA ${i + 1}/${allMangas.length}: ${manga.title} ---`);
console.log(`🔗 URL: ${manga.baseUrl}`);
try {
const response = await fetch(manga.baseUrl, {
credentials: 'include'
});
if (!response.ok) {
console.error(`❌ Error ${response.status} fetching page`);
continue;
}
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
// Usar la misma lógica de detección
let detectedPages = 'UNKNOWN';
const allDivs = doc.querySelectorAll('div');
for (let div of allDivs) {
const text = div.textContent.trim();
const pageMatch = text.match(/^(\d+)\s+pages?$/i);
if (pageMatch) {
detectedPages = parseInt(pageMatch[1]);
console.log(`✓ Found: "${text}" = ${detectedPages} pages (class: ${div.className})`);
break;
}
}
results.push({
title: manga.title,
url: manga.baseUrl,
pages: detectedPages
});
console.log(`📊 Result: ${detectedPages} pages`);
} catch (error) {
console.error(`❌ Error processing manga:`, error);
}
}
console.log('\n========== 📊 FINAL RESULTS ==========');
results.forEach((result, idx) => {
console.log(`${idx + 1}. ${result.pages} pages - ${result.title}`);
});
console.log('========================================\n');
}
function init() {
if (window.location.href.includes('/g/')) return;