Skip to content

Instantly share code, notes, and snippets.

@clouedoc
Last active April 14, 2021 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clouedoc/c71e984e502aa296e5a05b8ac014ddf5 to your computer and use it in GitHub Desktop.
Save clouedoc/c71e984e502aa296e5a05b8ac014ddf5 to your computer and use it in GitHub Desktop.
Studying triple click's event flow

Studying triple click's property

When should we send mousedown and mouseup events?

document.querySelector('body').onmousedown = () => console.log('mousedown; ' + new Date().getSeconds() + ":" + new Date().getUTCMilliseconds())
document.querySelector('body').onmouseup = () => console.log('mouseup; ' + new Date().getSeconds() + ":" + new Date().getUTCMilliseconds())

Gives:

mousedown; 20:19
mouseup; 20:69
mousedown; 20:150
mouseup; 20:234
mousedown; 20:305
mouseup; 20:360

First: mousedown Second: mouseup

There is a mouseup event for each mousedown event.

Between mouseup and mousedown (between clicks)

Delays

  • 81ms
  • 71ms

Generation: random(65, 230) seems reasonable.

Between mousedown and mouseup (click duration)

Delays:

  • 50ms
  • 84ms
  • 55ms

Generation: random(45, 120)

Final function

⚠️ spoiler: doesn't work at all!

// triple-click.ts
import { Page } from 'puppeteer';
import delay from 'delay';


/**
 * Triple click's at the current mouse's position in the page
 */
export async function tripleClick(page: Page) {
  for (let i = 0; i < 3; i++) {
    await page.mouse.down();
    await delay(random(45, 120)); // click duration
    await page.mouse.up();
    await delay(random(65, 230)); // delay between each click
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment