mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-11-16 17:08:33 +01:00
quick non-breaking non-essential fixes
This commit is contained in:
parent
efcefa7e85
commit
361e04f9d7
2 changed files with 12 additions and 11 deletions
|
@ -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
|
||||
|
|
17
index.js
17
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
|
||||
} 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(';');
|
||||
|
|
Loading…
Reference in a new issue