(page)
| 7 | } |
| 8 | |
| 9 | async function humanBehavior(page) { |
| 10 | // random mouse moves |
| 11 | for (let i = 0; i < 5; i++) { |
| 12 | const x = Math.floor(Math.random() * 700) + 100; |
| 13 | const y = Math.floor(Math.random() * 500) + 100; |
| 14 | await page.mouse.move(x, y, { steps: Math.floor(Math.random() * 20) + 5 }); |
| 15 | await sleep(Math.random() * 400 + 200); |
| 16 | } |
| 17 | |
| 18 | // scroll down in chunks |
| 19 | for (let i = 0; i < 3; i++) { |
| 20 | await page.evaluate(() => { |
| 21 | window.scrollBy(0, window.innerHeight * 0.8); |
| 22 | }); |
| 23 | await sleep(Math.random() * 700 + 500); |
| 24 | } |
| 25 | |
| 26 | // pause and scroll up |
| 27 | await sleep(Math.random() * 500 + 500); |
| 28 | await page.evaluate(() => { |
| 29 | window.scrollBy(0, -window.innerHeight * 0.5); |
| 30 | }); |
| 31 | await sleep(Math.random() * 500 + 300); |
| 32 | |
| 33 | // random click |
| 34 | const bx = Math.floor(Math.random() * 700) + 50; |
| 35 | const by = Math.floor(Math.random() * 500) + 50; |
| 36 | await page.mouse.click(bx, by); |
| 37 | await sleep(Math.random() * 1000 + 1000); |
| 38 | } |
| 39 | |
| 40 | (async () => { |
| 41 | const browser = await chromium.launch({ headless: true }); |
no test coverage detected