nightmare-load-filter

0.2.0 • Public • Published

nightmare-load-filter

Add pre-load content filtering to your Nightmare scripts.

Usage

Require the library and pass the Nightmare library as a reference to attach the plugin actions:

var Nightmare = require('nightmare');
require('nightmare-load-filter')(Nightmare);

.filter(filter, fn)

Adds a prerequest call to fn filtered to the URLs specified in filter. The fn parameter must be a function that accepts details and a callback. When complete, the callback must specify a response object, even if it is empty. Note that filter is of the same form and works in the same way that the Electron filter does. See the onBeforeRequest documentation in the Electron documentation for more information.

Example

yield nightmare
  .filter({
    urls:[
      'http://example.com'
    ]
  }, function(details, cb){
    //cancel a specific file
    return cb({cancel: (details.url === 'http://example.com/some-resource.js')});
  })
  .goto('http://example.com');

Package Sidebar

Install

npm i nightmare-load-filter

Weekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • rosshinkley