zfcsoftware / puppeteer-real-browser

This package is designed to bypass puppeteer's bot-detecting captchas such as Cloudflare. It acts like a real browser and can be managed with puppeteer.
https://www.npmjs.com/package/puppeteer-real-browser
MIT License
676 stars 86 forks source link

Support Puppeteer argument defaultViewport ? #132

Closed Zvih closed 1 month ago

Zvih commented 1 month ago

I tried setting the general argument "defaultViewport: null" to make the viewport cover the entire page, but it didn't work.

Thanks

... async getBrowserCF(visible, isIncognito = false) { let args;

    args = [];
    args.push('--no-sandbox');
    args.push('--disable-setuid-sandbox');
    args.push('--start-maximized');
    args.push('--disable-infobars');
    args.push('--window-position=0,0');
    args.push('--ignore-certificate-errors');
    args.push('--ignore-certificate-errors-spki-list');
    args.push('--disable-gpu');
    args.push('--disable-dev-shm-usage');
    args.push('--password-store=basic');

    if (isIncognito) {
        args.push('--incognito');
    }

    args.push('--window-size=' + this.width + ',' + this.height);

    const {page, browser} = await connect(
        {
            args: args,
            headless: !visible,
            customConfig: {
                defaultViewport: null,
                executablePath: this.executablePath,
                userDataDir: this.userDataDir,
                userAgent: '5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
                ignoreHTTPSErrors: true,
                ignoreDefaultArgs: [
                    '--disable-background-networking',
                    //'--enable-features=NetworkService,NetworkServiceInProcess',
                    //'--disable-background-timer-throttling',
                    //'--disable-backgrounding-occluded-windows',
                    //'--disable-breakpad',
                    //'--disable-client-side-phishing-detection',
                    '--disable-component-extensions-with-background-pages',
                    //'--disable-default-apps',
                    //'--disable-dev-shm-usage',
                    '--disable-extensions',
                    // BlinkGenPropertyTrees disabled due to crbug.com/937609
                    //'--disable-features=TranslateUI,BlinkGenPropertyTrees',
                    //'--disable-hang-monitor',
                    //'--disable-ipc-flooding-protection',
                    //'--disable-popup-blocking',
                    //'--disable-prompt-on-repost',
                    //'--disable-renderer-backgrounding',
                    //'--disable-sync',
                    //'--force-color-profile=srgb',
                    //'--metrics-recording-only',
                    //'--no-first-run',
                    //'--enable-automation',
                    //'--password-store=basic',
                    //'--use-mock-keychain',
                ]
            },

            skipTarget: [],
            fingerprint: true,
            turnstile: true,
            connectOption: {},
            fpconfig: {},
        });

    return {page, browser}
}
zfcsoftware commented 1 month ago

Hello, the project has been updated. Runtime is no longer used, so some issues like this appeared. Thanks for the problem. I will look into it.

zfcsoftware commented 1 month ago

https://github.com/zfcsoftware/puppeteer-real-browser?tab=readme-ov-file#pagesetviewport-method-is-not-working-what-should-i-do https://github.com/zfcsoftware/puppeteer-real-browser/blob/ecfcef6946d68b75e0e7d98dc21797a3c016b12c/test/esm/test.js#L13 You can use it like here.