mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-11-16 17:08:33 +01:00
commit
cf98f37284
1 changed files with 9 additions and 1 deletions
8
index.js
8
index.js
|
@ -14,6 +14,7 @@ program
|
||||||
.option('--w, [w]', 'width')
|
.option('--w, [w]', 'width')
|
||||||
.option('--h, [h]', 'height')
|
.option('--h, [h]', 'height')
|
||||||
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
||||||
|
.option('--el, [el]', 'element css selector')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (program.url) urlvalue = program.url
|
if (program.url) urlvalue = program.url
|
||||||
|
@ -35,7 +36,14 @@ console.log(fullPage);
|
||||||
if (program.emulate) await page.emulate(devices[program.emulate]);
|
if (program.emulate) await page.emulate(devices[program.emulate]);
|
||||||
await page.goto(urlvalue)
|
await page.goto(urlvalue)
|
||||||
if (program.waitfor) await page.waitFor(Number(program.waitfor))
|
if (program.waitfor) await page.waitFor(Number(program.waitfor))
|
||||||
|
if (program.el) {
|
||||||
|
const el = await page.$(program.el);
|
||||||
|
await el.screenshot({
|
||||||
|
path: `${await page.title()} ${program.emulate} ${program.el} ${d.getTime()}.png`
|
||||||
|
});
|
||||||
|
} else {
|
||||||
await page.screenshot({path: await page.title() + " " + program.emulate + " " + d.getTime() + '.png', fullPage: fullPage})
|
await page.screenshot({path: await page.title() + " " + program.emulate + " " + d.getTime() + '.png', fullPage: fullPage})
|
||||||
|
}
|
||||||
await page.emulateMedia('screen')
|
await page.emulateMedia('screen')
|
||||||
if (program.pdf) await page.pdf({ path: await page.title() + " " + program.emulate + " " + d.getTime() + '.pdf' })
|
if (program.pdf) await page.pdf({ path: await page.title() + " " + program.emulate + " " + d.getTime() + '.pdf' })
|
||||||
console.log(await page.title())
|
console.log(await page.title())
|
||||||
|
|
Loading…
Reference in a new issue