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!
This commit is contained in:
20
content.js
20
content.js
@@ -320,22 +320,40 @@
|
|||||||
const allDivs = doc.querySelectorAll('div');
|
const allDivs = doc.querySelectorAll('div');
|
||||||
console.log(`🔍 Buscando en ${allDivs.length} divs...`);
|
console.log(`🔍 Buscando en ${allDivs.length} divs...`);
|
||||||
|
|
||||||
|
const potentialMatches = [];
|
||||||
|
|
||||||
for (let div of allDivs) {
|
for (let div of allDivs) {
|
||||||
const text = div.textContent.trim();
|
const text = div.textContent.trim();
|
||||||
// Patrón específico: número seguido de "pages" o "page"
|
// Patrón específico: número seguido de "pages" o "page"
|
||||||
const pageMatch = text.match(/^(\d+)\s+pages?$/i);
|
const pageMatch = text.match(/^(\d+)\s+pages?$/i);
|
||||||
if (pageMatch) {
|
if (pageMatch) {
|
||||||
const pageCount = parseInt(pageMatch[1]);
|
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)
|
// Validar que sea un número razonable (1-100 páginas)
|
||||||
if (pageCount > 0 && pageCount <= 100) {
|
if (pageCount > 0 && pageCount <= 100) {
|
||||||
actualTotalPages = pageCount;
|
actualTotalPages = pageCount;
|
||||||
foundPageCount = true;
|
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;
|
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
|
// Si no se encontró, usar patrones alternativos
|
||||||
if (!foundPageCount) {
|
if (!foundPageCount) {
|
||||||
console.log('⚠️ No se encontró patrón específico, buscando alternativas...');
|
console.log('⚠️ No se encontró patrón específico, buscando alternativas...');
|
||||||
|
|||||||
Reference in New Issue
Block a user