import { chromium } from 'playwright-extra'; // Import from playwright-extra import StealthPlugin from 'puppeteer-extra-plugin-stealth' import yn from 'yn'; const test = async () => { const args = [ '--disable-blink-features=AutomationControlled', '--disable-web-security', '--no-sandbox', '--disable-dev-shm-usage', '--disable-features=site-per-process', '--disable-features=IsolateOrigins', '--disable-extensions', '--disable-infobars' ]; chromium.use(StealthPlugin()) // const browser = await this.getBrowserType().launch({ // args, // headless: yn(process.env.BROWSER_HEADLESS, { default: true }), // ...(process.env.PROXY_URL &&{ proxy: { // server: process.env.PROXY_URL, // }}) // }) const browser = await chromium.launch({ args, headless:false, proxy: { server: 'http://127.0.0.1:12334', }, }) const page = await browser.newPage(); console.log('Testing the stealth plugin..') await page.goto('https://www.suno.com/creat', { waitUntil: 'networkidle' }) // const frame = page.mainFrame(); // const captchaEl = await frame.$("iframe[src*='hcaptcha.com'], iframe[src*='challenges.cloudflare.com']"); const frame = page .frames() .find((f) => f.url().includes("hcaptcha.com") || f.url().includes("challenges.cloudflare.com")); if (frame) { console.log("检测到 Cloudflare 验证组件,开始调用 2Captcha..."); } console.log('All done, check the screenshot. ✨') }; test()