npm install consimilo-screengrab- Install from npm with npm install consimilo-screengrab
- Create a ScreenshotQueue
``js
import { ScreenshotQueue } from "consimilo-screengrab";
const ssQueue = new ScreenshotQueue({
baseFolder: "~/Documents",
threads: 1
});
``
- Add ScreenshotConfigsjs`
ssQueue.add([
{
url: "http://github.com",
width: "1200"
},
{
url: "http://google.com",
width: "900"
}
]);`
- Add event listenersjs`
ssQueue.on("screenshot_taken", function(screenshotPath) { });
ssQueue.on("start", function() { });
ssQueue.on("finished", function(screenshotPath) { });`
- Start the processjs`
ssQueue.start();
ScreenshotQueue is a constructor that can take the following options
- baseFolder: Required, sets the folder that images will be stored inthreads
- : Default: 1, sets the number of threads that run simultaneously
The .add method can take a single or multiple ScreenshotConfigs. Available options:url
- : Required, sets the URL that is scannedwidth
- : Optional, sets the width of the window when screenshot is grabbedelement
- : Optional, instead of taking a screenshot of the entire page, take a screenshot of a single elementhideElements
- : Optional, array of strings that can be passed to document.querySelectorAll()variations`: Optional, variations are a way to take multiple screenshots of the same url without reloading the page. It can take all of the above options, except url
-