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 🙏

© 2024 – Pkg Stats / Ryan Hefner

graviton

v0.3.1

Published

Headless browser for web testing, scrapping

Downloads

2

Readme

Graviton

Graviton is a headless browser based on Electron.

It's very similar to Nightmare, but evaluated directly by electron, without process fork and ipc communication.

Because graviton work directly over electron, this allows you to use all features of electron.
For example: listen all available callbacks, use events in callback, manipulate with WindowBrowser, WebContents, and other electron api.
Adding new features has become much easier.

I tried replicate Nightmare API, for simple and fast usage by users which have experience with Nightmare.
If anybody want to help identical copy Nightmare API, pull request welcome.

How to use

npm install electron-prebuild
npm install graviton
./node_modules/.bin/electron test.js

Example search in yahoo (like Nightmare yahoo example)

    var Graviton = require('./lib/graviton');
    var vo = require("vo");
    
    vo(run)(function (err, result) {
        if (err) throw err;
    });
    
    function *run() {
        var graviton = yield Graviton.new({electron: {
            show: true,
        }});
    
        yield graviton.goto('http://yahoo.com', "dom");
        yield graviton.type('#uh-search-box', 'github nightmare');
        yield graviton.click('#uh-search-button');
        yield graviton.wait('#main');
        console.log(yield graviton.evaluate(function () {
            return document.querySelector('#main .searchCenterMiddle li a').href
        }));
    
        yield graviton.end();
    }

Example

    var Graviton = require("graviton");
    var vo = require('vo');
   
    vo(run)(function (err, result) {
       if (err) throw err;
    });
    
    const GITHUB_LOGIN = '{SOME_LOGIN}';
    const GITHUB_PASS = '{SOME_PASS}';
    
    function *run() {
       var graviton = yield Graviton.new({
           electron: {
               show: true,
           }
       });
    
       try {
           yield graviton.goto("https://github.com/");
           yield graviton.evaluate(()=> {
               document.querySelector(`.header-actions .btn[href="/login"`).click();
           });
           yield graviton.wait();
           yield graviton.evaluate((GITHUB_LOGIN, GITHUB_PASS)=> {
               document.querySelector("#login_field").value = GITHUB_LOGIN;
               document.querySelector("#password").value = GITHUB_PASS;
               document.querySelector(".btn.btn-primary.btn-block").click();
           }, GITHUB_LOGIN, GITHUB_PASS);
    
           yield graviton.wait();
           console.log(yield graviton.evaluate(()=> {
               return document.title;
           }));
       } catch (e) {
           console.log(e);
       }
    
       yield graviton.end();
    }