Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-screenshot-cli

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-screenshot-cli - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

a.png

8

CHANGELOG.md
1.4.0 / 2018-02-12
==================
* Debug `--headless` switch by inverting behavior
* Offer a new flag for setting up default timeout duration
* Avoid asking Puppeteer to clip element on fullpage capture
* Catch errors from any calls to Puppeteer to finally close browser
1.3.1 / 2018-02-12

@@ -3,0 +11,0 @@ ==================

40

index.js

@@ -14,4 +14,5 @@ #!/usr/bin/env node

{ name: 'height', alias: 'h', type: Number, description: 'Viewport height in pixels \n[italic]{Default: 600}' + EOL },
{ name: 'timeout ', type: Number, description: 'Maximum time to wait for in milliseconds. \n[italic]{Default: 30000}' + EOL },
{ name: 'fullPage', alias: 'f', type: Boolean, description: 'When true, takes a screenshot of the full scrollable page. \n[italic]{Defaults: false}.' + EOL },
{ name: 'headless', type: Boolean, description: 'Whether to run browser in headless mode. \n[italic]{Default: true}' + EOL},
{ name: 'noheadless', type: Boolean, description: 'Allow disabling headless mode. \n[italic]{Default: false}' + EOL},
{ name: 'help', alias: '?', type: Boolean, description: 'This help' + EOL },

@@ -28,30 +29,37 @@ ];

quality,
noheadless,
selector = 'body',
width = 800,
height = 600,
headless = true,
timeout = 30000,
fullPage = false,
}) {
const browser = await puppeteer.launch({headless});
const browser = await puppeteer.launch({ headless: !noheadless });
const page = await browser.newPage();
await page.setViewport({ width, height });
page.setDefaultNavigationTimeout(timeout);
await page.goto(url, { waitUntil: [ 'load', 'networkidle0' ] });
try {
await page.setViewport({ width, height });
await page.waitForSelector(selector, { visible: true });
await page.goto(url, { waitUntil: [ 'load', 'networkidle0' ] });
const elementHandle = await page.$(selector);
await page.waitForSelector(selector, { visible: true, timeout });
output = output === '-' ? undefined : output;
type = type === 'jpg' ? 'jpeg' : type;
output = output === '-' ? undefined : output;
type = type === 'jpg' ? 'jpeg' : type;
const picture = await page.screenshot({
type, quality, fullPage,
path: output,
clip: await elementHandle.boundingBox(),
});
const picture = await page.screenshot({
type, quality, fullPage,
path: output,
clip: !fullPage && await (await page.$(selector)).boundingBox(),
});
if (!output) {
process.stdout.write(picture);
if (!output) {
process.stdout.write(picture);
}
} catch (error) {
await browser.close();
throw error;
}

@@ -58,0 +66,0 @@

2

package.json
{
"name": "puppeteer-screenshot-cli",
"version": "1.3.1",
"version": "1.4.0",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=6.4.0"

@@ -41,2 +41,5 @@ # Puppeteer screenshot CLI

--timeout number Maximum time to wait for in milliseconds.
Default: 30000
-f, --fullPage When true, takes a screenshot of the full scrollable page.

@@ -43,0 +46,0 @@ Defaults: false.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc