diff --git a/content.js b/content.js
index bd531a1..f56cd82 100644
--- a/content.js
+++ b/content.js
@@ -51,6 +51,7 @@
+
@@ -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;