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
|
||||
--el - css selector document.querySelector
|
||||
--auth - basic http authentication
|
||||
--no - exclude "image", "stylesheet", "script", "font"
|
||||
|
||||
<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://www.nytimes.com --no "image"
|
||||
|
||||
screenshoteer --url https://www.nytimes.com --no "script"
|
||||
|
||||
screenshoteer --url file:///Users/../index.html
|
||||
```
|
||||
<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('--el, [el]', 'element css selector')
|
||||
.option('--auth, [auth]', 'Basic HTTP authentication')
|
||||
.option('--no, [no]', 'Exclude')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!program.url) {
|
||||
|
@ -38,6 +39,15 @@ console.log(program.fullPage);
|
|||
async function execute() {
|
||||
const browser = await puppeteer.launch();
|
||||
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();
|
||||
if (program.w || program.h) {
|
||||
const newWidth = !program.w?600:program.w
|
||||
|
@ -53,7 +63,7 @@ console.log(program.fullPage);
|
|||
if (program.auth) {
|
||||
const [username, password] = program.auth.split(';');
|
||||
await page.authenticate({ username, password });
|
||||
}
|
||||
}
|
||||
await page.goto(program.url);
|
||||
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-');
|
||||
if (program.waitfor) await page.waitFor(Number(program.waitfor));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "screenshoteer",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "Make screenshots and device emulations form your terminal",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue