Add debug logging to content script to diagnose 0 products issue

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 18:06:00 -04:00
parent 9d49a99916
commit 2da4e1856f
+36
View File
@@ -8,6 +8,7 @@
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "extractProducts") {
console.log("[Pokemon Monitor] Extracting products...");
debugPageContent();
const products = extractProducts();
console.log("[Pokemon Monitor] Found", products.length, "products");
sendResponse(products);
@@ -15,6 +16,41 @@
return true;
});
// Debug function to see what's on the page
function debugPageContent() {
console.log("[Pokemon Monitor] === PAGE DEBUG ===");
console.log("[Pokemon Monitor] Title:", document.title);
console.log("[Pokemon Monitor] Body text length:", document.body?.textContent?.length || 0);
// Check for bot protection indicators
const bodyText = document.body?.textContent?.toLowerCase() || "";
if (bodyText.includes("verify") || bodyText.includes("robot") || bodyText.includes("captcha")) {
console.log("[Pokemon Monitor] WARNING: Possible bot protection detected!");
}
// Count all links
const allLinks = document.querySelectorAll('a');
console.log("[Pokemon Monitor] Total links on page:", allLinks.length);
// Check for product links with various patterns
const productLinks = document.querySelectorAll('a[href*="/product/"]');
console.log("[Pokemon Monitor] Links with /product/:", productLinks.length);
// Try alternative selectors
const cardLinks = document.querySelectorAll('[class*="product"] a, [class*="card"] a, [class*="tile"] a');
console.log("[Pokemon Monitor] Links in product/card/tile containers:", cardLinks.length);
// Sample some hrefs to understand page structure
const sampleHrefs = Array.from(allLinks).slice(0, 10).map(a => a.href);
console.log("[Pokemon Monitor] Sample hrefs:", sampleHrefs);
// Look for any elements that might be products
const possibleProducts = document.querySelectorAll('[class*="product"], [class*="card"], [data-product], [data-item]');
console.log("[Pokemon Monitor] Elements with product/card classes:", possibleProducts.length);
console.log("[Pokemon Monitor] === END DEBUG ===");
}
function extractProducts() {
const products = [];