const puppeteer = require('puppeteer');
const AuthHelper = require('./auth_helper');

async function quickScreenshot() {
    const browser = await puppeteer.launch({
        headless: false, // Show browser
        args: ['--no-sandbox', '--disable-setuid-sandbox']
    });

    try {
        const page = await browser.newPage();
        await page.setViewport({ width: 375, height: 667, isMobile: true });

        const auth = new AuthHelper(page);
        await auth.ensureAuthenticated();

        // Just navigate and immediately screenshot
        page.goto('http://127.0.0.1:5000/settings/').catch(() => {});
        await new Promise(resolve => setTimeout(resolve, 3000));

        await page.screenshot({ path: './settings-quick.png' });
        console.log('📸 Screenshot saved');

        // Get page info
        const info = await page.evaluate(() => {
            return {
                url: window.location.href,
                title: document.title,
                bodyHeight: document.body.scrollHeight
            };
        });
        console.log('Page info:', info);

    } finally {
        await browser.close();
    }
}

quickScreenshot().catch(console.error);
