mirror of
https://github.com/vladocar/screenshoteer.git
synced 2025-01-03 03:22:11 +01:00
Adding -click parameter
This commit is contained in:
parent
4718dfb47f
commit
1d8dcda944
3 changed files with 9 additions and 4 deletions
|
@ -38,6 +38,7 @@ Parameters:
|
||||||
--el - css selector document.querySelector
|
--el - css selector document.querySelector
|
||||||
--auth - basic http authentication
|
--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>
|
<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 "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
|
screenshoteer --url file:///Users/../index.html
|
||||||
```
|
```
|
||||||
|
|
2
index.js
2
index.js
|
@ -15,6 +15,7 @@ program
|
||||||
.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')
|
.option('--no, [no]', 'Exclude')
|
||||||
|
.option('--click, [click]', 'Click')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (!program.url) {
|
if (!program.url) {
|
||||||
|
@ -67,6 +68,7 @@ console.log(program.fullPage);
|
||||||
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));
|
||||||
|
if (program.click) await page.click(program.click);
|
||||||
if (program.el) {
|
if (program.el) {
|
||||||
const el = await page.$(program.el);
|
const el = await page.$(program.el);
|
||||||
await el.screenshot({path: `${title} ${program.emulate} ${program.el} ${timestamp}.png`});
|
await el.screenshot({path: `${title} ${program.emulate} ${program.el} ${timestamp}.png`});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "screenshoteer",
|
"name": "screenshoteer",
|
||||||
"version": "1.0.6",
|
"version": "1.0.7",
|
||||||
"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