ghost-cursor
ghost-cursor copied to clipboard
Sometimes it doesn't work on iframes
When i use page.on('request') to modify the html of "discord.com" to show a hcaptcha iframe the cursor doesn't load on that iframe, but if the url is something else, for example accounts.hcaptcha.com the cursor loads on that iframe. There must be something wrong with the cursor code. Here's a short example:
const puppeteer = require('puppeteer');
const { createCursor, getRandomPagePoint, installMouseHelper } = require('ghost-cursor');
(async () => {
const browser = await puppeteer.launch({ headless: false});
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (req) => {
if (req.url() === "https://discord.com/") {
req.respond({
status: 200,
body: `<!DOCTYPE html>
<html lang="en">
<script src="https://js.hcaptcha.com/1/api.js?reportapi=https%3A%2F%2Faccounts.hcaptcha.com&custom=False" type="text/javascript" async defer></script>
<div id="hcaptcha-demo" class="h-captcha" data-sitekey="4c672d35-0701-42b2-88c3-78380b0db560" data-callback="onSuccess" data-expired-callback="onExpire"></div>
</html>`
})
}
else {
req.continue();
}
});
const cursor = createCursor(page);
await installMouseHelper(page)
await page.goto('https://discord.com/');
})();
In this example, the site discord.com loads with my own html which is just an iframe, and the cursor doesn't show on this iframe, if the url is something else it shows.