mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-11-16 17:08:33 +01:00
Adding new --no exclude parameter
This commit is contained in:
parent
eb1dfc8f21
commit
04a67c82d0
3 changed files with 17 additions and 2 deletions
|
@ -36,6 +36,7 @@ Parameters:
|
||||||
--waitfor - wait time for the page load in milliseconds
|
--waitfor - wait time for the page load in milliseconds
|
||||||
--el - css selector document.querySelector
|
--el - css selector document.querySelector
|
||||||
--auth - basic http authentication
|
--auth - basic http authentication
|
||||||
|
--no - exclude "image", "stylesheet", "script", "font"
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
@ -60,6 +61,10 @@ screenshoteer --url https://news.ycombinator.com/item?id=18598672 --el ".fatite
|
||||||
|
|
||||||
screenshoteer --url https://site.com --auth "username;password"
|
screenshoteer --url https://site.com --auth "username;password"
|
||||||
|
|
||||||
|
screenshoteer --url https://www.nytimes.com --no "image"
|
||||||
|
|
||||||
|
screenshoteer --url https://www.nytimes.com --no "script"
|
||||||
|
|
||||||
screenshoteer --url file:///Users/../index.html
|
screenshoteer --url file:///Users/../index.html
|
||||||
```
|
```
|
||||||
<p> List of of supported mobile devices: https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js
|
<p> List of of supported mobile devices: https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js
|
||||||
|
|
12
index.js
12
index.js
|
@ -14,6 +14,7 @@ program
|
||||||
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
||||||
.option('--el, [el]', 'element css selector')
|
.option('--el, [el]', 'element css selector')
|
||||||
.option('--auth, [auth]', 'Basic HTTP authentication')
|
.option('--auth, [auth]', 'Basic HTTP authentication')
|
||||||
|
.option('--no, [no]', 'Exclude')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (!program.url) {
|
if (!program.url) {
|
||||||
|
@ -38,6 +39,15 @@ console.log(program.fullPage);
|
||||||
async function execute() {
|
async function execute() {
|
||||||
const browser = await puppeteer.launch();
|
const browser = await puppeteer.launch();
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
|
if (program.no) {
|
||||||
|
await page.setRequestInterception(true);
|
||||||
|
page.on('request', request => {
|
||||||
|
if (request.resourceType() === program.no)
|
||||||
|
request.abort();
|
||||||
|
else
|
||||||
|
request.continue();
|
||||||
|
});
|
||||||
|
}
|
||||||
const timestamp = new Date().getTime();
|
const timestamp = new Date().getTime();
|
||||||
if (program.w || program.h) {
|
if (program.w || program.h) {
|
||||||
const newWidth = !program.w?600:program.w
|
const newWidth = !program.w?600:program.w
|
||||||
|
@ -53,7 +63,7 @@ console.log(program.fullPage);
|
||||||
if (program.auth) {
|
if (program.auth) {
|
||||||
const [username, password] = program.auth.split(';');
|
const [username, password] = program.auth.split(';');
|
||||||
await page.authenticate({ username, password });
|
await page.authenticate({ username, password });
|
||||||
}
|
}
|
||||||
await page.goto(program.url);
|
await page.goto(program.url);
|
||||||
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-');
|
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-');
|
||||||
if (program.waitfor) await page.waitFor(Number(program.waitfor));
|
if (program.waitfor) await page.waitFor(Number(program.waitfor));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "screenshoteer",
|
"name": "screenshoteer",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"description": "Make screenshots and device emulations form your terminal",
|
"description": "Make screenshots and device emulations form your terminal",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in a new issue