diff --git a/src/spoof.ts b/src/spoof.ts index ea6d4dc..3d6b38c 100644 --- a/src/spoof.ts +++ b/src/spoof.ts @@ -515,7 +515,7 @@ export class GhostCursor { // Exit function if the browser is no longer connected if (!this.page.browser().isConnected()) return - log('Warning: could not move mouse, error message:', error) + log('Warning: Could not move mouse. Error message: ', error) } } } @@ -623,7 +623,14 @@ export class GhostCursor { await delay(optionsResolved.waitForClick) await this.mouseUp() } catch (error) { - log('Warning: could not click mouse, error message:', error) + // use JS click method as a fallback + log('Warning: Could not click mouse using CDP. Falling back to JS click method. Error message: ', error) + await this.page.evaluate(() => { + const element = document.elementFromPoint(this.location.x, this.location.y) as HTMLElement | null + if (element != null) { + element.click() + } + }) } await delay(optionsResolved.moveDelay * (optionsResolved.randomizeMoveDelay ? Math.random() : 1))