Closed teammakdi closed 6 months ago
import puppeteer from 'puppeteer';
import { createCursor } from 'ghost-cursor'
function getRandomNumber (x) {
return Math.ceil(Math.random() * x)
}
(async () => {
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
await page.goto('https://infosimples.github.io/detect-headless/');
const width = 1080;
const height = 1024;
await page.setViewport({width: width, height: height});
await new Promise(resolve => setTimeout(resolve, 2000));
const cursor = createCursor(page)
cursor.toggleRandomMove(true)
await cursor.moveTo({
x: getRandomNumber(width),
y: getRandomNumber(height)
})
await new Promise(resolve => setTimeout(resolve, 2000));
await cursor.moveTo({
x: getRandomNumber(width),
y: getRandomNumber(height)
})
await new Promise(resolve => setTimeout(resolve, 2000));
await cursor.moveTo({
x: getRandomNumber(width),
y: getRandomNumber(height)
})
await new Promise(resolve => setTimeout(resolve, 2000));
await browser.close();
})();
Not sure if there's any better way to do the same.
For me too its not clear the use of toggleRandomMove(). Does it move randomly, when or how much? Seems like its used to create a random movement before going to the desired position. Btw the esiest solution for you would be to create a wrapper function.
@marcusdiy it is always doing it while no action for the mouse is set. So if you are typing after mouse action you have to disable it.
Hi, I'm looking how to make random mouse movement (random starting and ending points within viewport) to avoid headless detection.