Nick

Nick([options])

This is Nick's constructor. options is an optional argument that lets you configure your Nick instance.

const Nick = require("nickjs")
const nick = new Nick()
var Nick = require('nickjs')
var nick = new Nick()
const Nick = require("nickjs")

const nick = new Nick({
  printNavigation: true,
  printResourceErrors: true,
  printPageErrors: true,
  resourceTimeout: 10000,
  userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
  blacklist: [
    "sidecar.gitter.Im",
    /^.*\.woff$/
   	]
})
var Nick = require('nickjs')

var nick = new Nick({
  printNavigation: true,
  printResourceErrors: true,
  printPageErrors: true,
  resourceTimeout: 10000,
  userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
  blacklist: [
    "sidecar.gitter.Im",
    /^.*\.woff$/
  ]
})

NickJS must be instantiated only once. Behind the scenes, the headless browser driver is initialized. The next step is to open a tab with newTab().

— [options] (PlainObject)

Optional settings for the Nick instance.

  • printNavigation (Boolean): when true (the default), Nick will log important navigation information like page changes, redirections and form submissions
  • printResourceErrors (Boolean): when true (the default), Nick will log all the errors encountered when loading pages, images and all other resources needed by the pages you visit
  • printPageErrors (Boolean): when true (the default), Nick will log all JavaScript errors and exceptions coming from the scripts executed in the page context
  • printAborts (Boolean): when true (the default), Nick will log requests aborted by the blacklist or whitelist
  • timeout (Number): milliseconds after which Nick will abort loading a resource (page, images and all other resources needed by the pages you visit) — defaults to 10000ms (note: this only works for "page open" timeouts when using Chrome)
  • userAgent (String): sets the User-Agent header — by default NickJS uses an innocuous looking macOS Chrome user agent string
  • loadImages (Boolean): whether or not to load the images embedded in the pages (defaults to true) — can also be configured by setting the environment variable NICKJS_LOAD_IMAGES to 0 or 1 (however, this constructor option takes precedence)
  • blacklist (Array): a list of URLs as strings or regexes (can be a mix of both) that will be blocked from loading (strings will only match the beginning of the URL and the protocol portion can be omitted)
  • whitelist (Array): a list of URLs as strings or regexes (can be a mix of both) that are the only URLs allowed to load (strings will only match the beginning of the URL and the protocol portion can be omitted) — note: the blacklist is applied after the whitelist
  • httpProxy (String): HTTP or HTTPS proxy to use in the form username:[email protected]:3128 (NickJS does not yet support other types of proxies) — can also be configured by setting the environment variable NICKJS_PROXY or HTTP_PROXY or http_proxy (however, this constructor option takes precedence)
  • width (Number): Viewport width (defaults to 1280)
  • height (Number): Viewport height (defaults to 800)
  • debug (Boolean): print internal debugging information if available (enable this only if you know what you're doing)