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

linkquest-screenshot

v1.0.2

Published

Takes a screenshot of the page or pages being processed with Linkquest

Downloads

2

Readme

Linkquest Screenshot

linkquest-screenshot is a plugin for Linkquest that can take various sizes of screenshots of each page that Linkquest visits.

NPM version Known Vulnerabilities npm NPM downloads Gitter

Install

To install linkquest-screenshot you can use:

$ npm install linkquest-screenshot

Usage

To use linkquest-screenshot you must register it with linkquest like so:

const linkquest = new Linkquest('http://example.com/', { silent: true });

linkquest.register(require('linkquest-screenshot'), {
  // Defines the directory where the screenshots will be output to.
  output: screenshotsDir,
  // Defines a collection of sizes to screenshot.
  sizes: {
    // Describes the device type the screenshots are intended for.
    mobile: {
      // Describes the device and the width x height of the device screen in pixels.
      pixel: [411, 731],
      iphone: [375, 812]
    },
    tablet: {
      ipad: [768, 1024],
      galaxy: [360, 640]
    },
    desktop: {
      hdr: [1920, 1080]
    }
  }
});

await linkquest.start();

You can see that linkquest's register method takes the plugin as the first parameter and then the plugin's options as the second parameter.

This will crawl the page and save the output to the current working directory. If you want to instead crawl the whole host, you want to use:

Options

The options that can be passed to linkquest-screenshot are as follows:

| param | type | description | default | |--------------------------------- |-------- |--------------------------------------------------------------------------------------------- |---------------- | | options | Object | | | | options.output | string | Where should the outputted screenshots be saved to. | proccess.cwd() | | options.sizes | Object | The sizes for the screenshots to generate. | {} | | options.sizes.deviceType | Object | Describes the device type the screenshots are intended for. | {} | | options.sizes.deviceType.device | Object | Describes the device and the width x height of the device screen in pixels. | {} |

Example:

This example explains the code shown in the usage above.

Going through this line by line:

Line 1: Of course to be able to use the plugin, we need to require the base Linkquest module and we're just passing the silent = false flag to it to hide output.

Line 3: Here we use the register method of Linkquest to add a reference to our plugin, and then as the second parameter we pass an Object of options for the plugin.

Line 4: One of the options for this plugin is output which specifies the directory that the screenshots will be stored in. If the directory does not yet exist, then it will be created. By default this plugin will use process.cwd() as the default directory for storing screenshots.

Line 5-17: Here we are specifying 3 device types: mobile, tablet, and desktop. Under each device type we are specifying one or two devices for each one with the first index of the array being the width and the second being the height. You'll notice that the second index of the hdr array is '*' which tells the plugin that it should take a screenshot of the full height of the page.

const linkquest = new Linkquest('http://example.com/', { silent: true });

linkquest.register(require('../build/index'), {
  output: screenshotsDir,
  sizes: {
    mobile: {
      pixel: [411, 731],
      iphone: [375, 812]
    },
    tablet: {
      ipad: [768, 1024],
      galaxy: [360, 640]
    },
    desktop: {
      hdr: [1920, '*']
    }
  }
});

await linkquest.start();

Tests

To run the available tests for linkquest-screenshot use:

npm run test

License

MIT