import { chromium } from 'playwright'; import { bypassAgeGatePlaywright } from './src/utils/age-gate-playwright'; async function diagnoseCuraleafPage() { const browser = await chromium.launch({ headless: true }); const context = await browser.newContext({ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', viewport: { width: 1280, height: 720 } }); const page = await context.newPage(); try { console.log('Loading Curaleaf page...'); await page.goto('https://curaleaf.com/stores/curaleaf-dispensary-48th-street', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(2000); console.log('Bypassing age gate...'); const bypassed = await bypassAgeGatePlaywright(page, 'Arizona'); if (!bypassed) { console.log('āŒ Failed to bypass age gate'); await browser.close(); return; } console.log('āœ… Age gate bypassed!'); console.log(`Current URL: ${page.url()}`); await page.waitForTimeout(5000); // Check page title const title = await page.title(); console.log(`\nPage title: ${title}`); // Check for "menu" or "shop" links const menuLinks = await page.locator('a:has-text("menu"), a:has-text("shop"), a:has-text("order")').count(); console.log(`\nMenu/Shop links found: ${menuLinks}`); if (menuLinks > 0) { const links = await page.locator('a:has-text("menu"), a:has-text("shop"), a:has-text("order")').all(); console.log('\nMenu links:'); for (const link of links.slice(0, 5)) { const text = await link.textContent(); const href = await link.getAttribute('href'); console.log(` - ${text}: ${href}`); } } // Check body text const bodyText = await page.textContent('body') || ''; console.log(`\nBody text length: ${bodyText.length} characters`); console.log(`Contains "menu": ${bodyText.toLowerCase().includes('menu')}`); console.log(`Contains "shop": ${bodyText.toLowerCase().includes('shop')}`); console.log(`Contains "product": ${bodyText.toLowerCase().includes('product')}`); console.log(`Contains "dutchie": ${bodyText.toLowerCase().includes('dutchie')}`); // Take screenshot await page.screenshot({ path: '/tmp/curaleaf-diagnosed.png', fullPage: true }); console.log('\nšŸ“ø Screenshot saved: /tmp/curaleaf-diagnosed.png'); } catch (error) { console.error('Error:', error); } finally { await browser.close(); } } diagnoseCuraleafPage();