From 361e04f9d733b07006bcfa4b6b2a10bf452a19b7 Mon Sep 17 00:00:00 2001 From: Jesus Martinez <71607977+Martje55555@users.noreply.github.com> Date: Sat, 24 Jul 2021 21:26:12 -0500 Subject: [PATCH] quick non-breaking non-essential fixes --- README.md | 4 ++-- index.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b98cda4..cd39dda 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ npm i -g screenshoteer ```shell screenshoteer --url https://www.example.com -or .html localy copy the url path from the browser +or .html locally copy the url path from the browser screenshoteer --url file:///Users/../index.html screenshoteer --url file:///C:/Users/../Random-HTML-file.html @@ -32,7 +32,7 @@ Parameters: -h help --url web page url --emulate - emulate web device example: --emulate "iPhone 6" ---fullpage - can be true or false. It will take screenshot of entire web page if is true. True is the default parameter. +--fullpage - can be true or false. It will take screenshot of entire web page if it is true. True is the default parameter. --pdf - generate additional pdf --w - width of the Web Page in px --h - height of the Web Page in px diff --git a/index.js b/index.js index 7c3b90c..419f3ff 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ #!/usr/bin/env node const puppeteer = require('puppeteer'); -const devices = require('puppeteer/DeviceDescriptors'); const program = require('commander'); program @@ -51,18 +50,19 @@ const deviceName = puppeteer.devices[program.emulate]; if (program.no) { await page.setRequestInterception(true); page.on('request', request => { - if (request.resourceType() === program.no) + if (request.resourceType() === program.no) { request.abort(); - else - request.continue(); + } else { + request.continue(); + } }); } const timestamp = new Date().getTime(); if (program.w || program.h) { - const newWidth = !program.w?600:program.w - const newHeight = !program.h?'0':program.h + const newWidth = !program.w?600:program.w; + const newHeight = !program.h?'0':program.h; if (program.h && !program.fullpage) program.fullPage = false; - await page.setViewport({width: Number(newWidth), height: Number(newHeight)}) + await page.setViewport({width: Number(newWidth), height: Number(newHeight)}); } if (program.theme) { await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: program.theme }]); @@ -70,10 +70,11 @@ const deviceName = puppeteer.devices[program.emulate]; if (program.vd) { await page.emulateVisionDeficiency(program.vd); } - if (program.emulate) + if (program.emulate) { await page.emulate(deviceName); - else + } else { program.emulate = ''; + } if (program.auth) { const [username, password] = program.auth.split(';');