Menu

gitpiper

Gremlins.js Cheat Sheet in April 2024

Last Updated: 11 April 2024

README.md

Example

Simple example

<script src='https://cdn.jsdelivr.net/npm/gremlins/dist/gremlins.js'></script>
<script>
gremlins.createHorde().unleash()
</script>

Custom gremlins

gremlins.createHorde()
  .allGremlins()
  .gremlin(function () {
    document.activeElement.blur()
  })

{: data-line=“3,4,5”}

Runs the given function at regular intervals.

Full example

gremlins.createHorde()
  .gremlin(gremlins.species.formFiller())
  .gremlin(gremlins.species.clicker()
    .clickTypes(['click'])
    .canClick(element => { ··· })
    .showAction((x, y) => { ··· }))
  .gremlin(gremlins.species.scroller())
  .mogwai(gremlins.mogwais.alert())
  .mogwai(gremlins.mogwais.fps())
  .mogwai(gremlins.mogwais.gizmo().maxErrors(2))
  .unleash()

By default, all gremlins and mogwais species are added to the horde. Do it this way to customize gremlins.

See: Specifying gremlins

Hooks

Before and after

gremlins.createHorde()
  .before(function () {
    this.log('sync')
    console.profile('gremlins')
  })
  .after(function () {
    this.log('done')
    console.profileEnd()
  })

{: data-line=“2,6”}

Asynchronous

gremlins.createHorde()
  .before(function (done) {
    setTimeout(() => {
      this.log('async')
      done()
    }, 500)
  })

{: data-line=“2”}

References


338+ more cheat sheets for you in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️