Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick non-breaking non-essential fixes #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const program = require('commander');

program
Expand Down Expand Up @@ -51,29 +50,31 @@ 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 }]);
}
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(';');
Expand Down