npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nightmare-scripted

v0.1.0

Published

Run portable scripts through Nightmare

Readme

Nightmare Scripted

Nightmare scripted is a wrapper around Nightmare by segmentio which allows JSON scripting on the nightmare object.

Note: this module should never be used on a production server or any server where inputs can not be trusted this module uses eval() to convert strings to functions and could be a security risk in most cases.

Installation

npm install nightmare-scripted

Usage

Refer to the Nightmare documentation at https://github.com/segmentio/nightmare

Including/Initialization

Nightmare must be initialized before use. This can be done on import or as a function call.

const nightmareScripted = require('nightmare-scripted')({electronPath: require('./node_modules/electron'),show: false});

or

const nightmareScripted = require('nightmare-scripted')();
nighmareScripted.init({electronPath: require('./node_modules/electron'),show: false});

Running a script

To run a script use the .run(script) function. It is await-able/then-able

(async()=>{

let Script = JSON.stringify("[{'goto': ['https://en.wikipedia.org/wiki/Template:Nevada_County,_California']},{'cookies.clear': []},{'wait': ['body']},{'evaluate': [`()=>{const ghostTown = document.querySelector('tr > th > a[title="Ghost town"]');const row = ghostTown.parentElement.parentElement;const towns = Array.from(row.querySelectorAll('li > a')).map((el) => el.href);return towns;}`]}]);";

let res = await nighmareScripted.run(Script);
console.log(res);

})();

Available Functions

Most nightmare chainable functions are available.

goto useragent authentication end halt back forward refresh click mousedown mouseup mouseover mouseout type insert check uncheck select scrollTo viewPort inject evaluate wait waitfn header exists visible on once removeListener screenshot html pdf title url path cookies.get cookies.set cookies.clear

end

Passing end is optional at the end of your script. It will be called automatically after all of your scripted functions are run.

wait and waitfn

For code simplicity ``wait(fn[, arg1, arg2,...]) has been replaced with waitfn(fn[, arg1, arg2,...]);

wait still accepts a ms integer or a string selector.

Script format

Scripts are formatted as an array of objects. Both JSON string representation and JavaScript arrays are accepted. Objects should have a key with the name of the function and a value with the arguments as an array. It is best practice to set an empty array when no arguments are to be passed (though you can set it to undefined).


[
    {'goto': ['http://google.com']},
    {'type': ['input.gLFyf.gsfi', 'Lets search the web']},
    {'click':['.gbqfbb']},
    {'end':[]},
]