import puppeteer from 'puppeteer-extra'; import StealthPlugin from 'puppeteer-extra-plugin-stealth'; import { bypassAgeGate, setAgeGateCookies } from './src/utils/age-gate'; puppeteer.use(StealthPlugin()); async function test() { const browser = await puppeteer.launch({ headless: 'new', args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-blink-features=AutomationControlled' ] }); const page = await browser.newPage(); await page.setViewport({ width: 1920, height: 1080 }); await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'); const url = 'https://curaleaf.com/stores/curaleaf-az-48th-street'; console.log('Setting age gate cookies before navigation...'); await setAgeGateCookies(page, url, 'Arizona'); console.log('Loading Curaleaf page...'); await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 }); await page.waitForTimeout(3000); console.log(`\nURL after navigation: ${page.url()}`); // Try to bypass if age gate still appeared const success = await bypassAgeGate(page, 'Arizona'); console.log(`\nFinal URL: ${page.url()}`); console.log(`Result: ${page.url().includes('/age-gate') ? '❌ FAILED - Still at age gate' : '✅ SUCCESS - Past age gate'}`); await browser.close(); process.exit(page.url().includes('/age-gate') ? 1 : 0); } test().catch(console.error);