nightmare-navigation-lock

0.2.0 • Public • Published

nightmare-navigation-lock

Usage

Require the library:

var Nightmare = require('nightmare');
require('nightmare-navigation-lock')(Nightmare);

... and then you're able to use lockNavigation and unlockNavigation.

.lockNavigation([eventArguments])

Locks almost all kinds of navigation (see note below). Optional event arguments can be provided by Electron function name so the Nightmare process can receive the events it is expecting to move on. Arguments must be of the form:

{
  loadURL: {
    'goto':['arg1', 'arg2' ...]
  }
}

By default, the loadURL argument is specified so nightmare.goto() works properly.

.unlockNavigation()

Unlocks navigation.

Important note about hash navigation

Electron does not expose a method to prevent hash navigation up front per the will-navigate documentation. This means that navigation cannot be locked for hash navigation.

Example

var Nightmare = require('nightmare');
require('nightmare-navigation-lock')(Nightmare);
var nightmare = Nightmare();
nightmare
 .goto('http://some-url.tld')
 .lockNavigation()
 .goto('http://some-other-url.tld')
 .url()
 .then(function(url){
   //url should equal 'http://some-url.tld'
  });

Package Sidebar

Install

npm i nightmare-navigation-lock

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • rosshinkley