mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-12-22 05:32:21 +01:00
Adding -click parameter
This commit is contained in:
parent
4718dfb47f
commit
1d8dcda944
3 changed files with 9 additions and 4 deletions
|
@ -37,7 +37,8 @@ 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"
|
||||
--no - exclude "image", "stylesheet", "script", "font"
|
||||
--click - example: ".selector>a" excellent way to close popups or to click some buttons on the page.
|
||||
|
||||
<p>
|
||||
|
||||
|
@ -64,7 +65,9 @@ screenshoteer --url https://site.com --auth "username;password"
|
|||
|
||||
screenshoteer --url https://www.nytimes.com --no "image"
|
||||
|
||||
screenshoteer --url https://www.nytimes.com --no "script" M
|
||||
screenshoteer --url https://www.nytimes.com --no "script"
|
||||
|
||||
screenshoteer --url https://www.economist.com/ --click ".ribbon__close-button"
|
||||
|
||||
screenshoteer --url file:///Users/../index.html
|
||||
```
|
||||
|
|
4
index.js
4
index.js
|
@ -15,6 +15,7 @@ program
|
|||
.option('--el, [el]', 'element css selector')
|
||||
.option('--auth, [auth]', 'Basic HTTP authentication')
|
||||
.option('--no, [no]', 'Exclude')
|
||||
.option('--click, [click]', 'Click')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!program.url) {
|
||||
|
@ -59,7 +60,7 @@ console.log(program.fullPage);
|
|||
await page.emulate(devices[program.emulate]);
|
||||
else
|
||||
program.emulate = '';
|
||||
|
||||
|
||||
if (program.auth) {
|
||||
const [username, password] = program.auth.split(';');
|
||||
await page.authenticate({ username, password });
|
||||
|
@ -67,6 +68,7 @@ console.log(program.fullPage);
|
|||
await page.goto(program.url);
|
||||
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-');
|
||||
if (program.waitfor) await page.waitFor(Number(program.waitfor));
|
||||
if (program.click) await page.click(program.click);
|
||||
if (program.el) {
|
||||
const el = await page.$(program.el);
|
||||
await el.screenshot({path: `${title} ${program.emulate} ${program.el} ${timestamp}.png`});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "screenshoteer",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "Make screenshots and device emulations form your terminal",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue