From 8cc0ba55346803f16b2404f9c31063ad709fdf4a Mon Sep 17 00:00:00 2001 From: renato97 Date: Tue, 4 Nov 2025 05:34:17 +0000 Subject: [PATCH] Add detailed page detection logging Now logs: - Every div that matches 'X pages' pattern - The text content of each match - The page count found - The div's className and ID - Whether it was ACCEPTED or REJECTED - All potential matches in an array - Why counts are rejected (out of range) This will show us exactly what's being detected as 213, 28, and 2832 pages! --- content.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/content.js b/content.js index f17c987..bd531a1 100644 --- a/content.js +++ b/content.js @@ -320,22 +320,40 @@ const allDivs = doc.querySelectorAll('div'); console.log(`🔍 Buscando en ${allDivs.length} divs...`); + const potentialMatches = []; + for (let div of allDivs) { const text = div.textContent.trim(); // Patrón específico: número seguido de "pages" o "page" const pageMatch = text.match(/^(\d+)\s+pages?$/i); if (pageMatch) { const pageCount = parseInt(pageMatch[1]); + potentialMatches.push({ + div: div, + text: text, + count: pageCount, + className: div.className, + id: div.id + }); + console.log(`🔍 Found potential match: "${text}" -> ${pageCount} pages (class: ${div.className}, id: ${div.id})`); + // Validar que sea un número razonable (1-100 páginas) if (pageCount > 0 && pageCount <= 100) { actualTotalPages = pageCount; foundPageCount = true; - console.log(`✓ Patrón específico "X pages": ${actualTotalPages} páginas (div: ${div.className})`); + console.log(`✓✅ ACCEPTED: "${text}" -> ${actualTotalPages} páginas (class: ${div.className})`); break; + } else { + console.log(`❌ REJECTED: ${pageCount} pages (out of range 1-100)`); } } } + console.log(`📊 Total potential matches found: ${potentialMatches.length}`); + if (potentialMatches.length > 0) { + console.log('📋 All matches:', potentialMatches); + } + // Si no se encontró, usar patrones alternativos if (!foundPageCount) { console.log('⚠️ No se encontró patrón específico, buscando alternativas...');