mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-11-16 17:08:33 +01:00
Windows safe filename regex
This commit is contained in:
parent
b7a530e575
commit
904aa80fa1
2 changed files with 7 additions and 5 deletions
10
index.js
10
index.js
|
@ -35,17 +35,19 @@ console.log(fullPage);
|
|||
if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)})
|
||||
if (program.emulate) await page.emulate(devices[program.emulate]);
|
||||
await page.goto(urlvalue)
|
||||
const title = await page.title()
|
||||
const t = title.replace(/[/\\?%*:|"<>]/g, '-')
|
||||
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`
|
||||
path: `${t} ${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: t + " " + program.emulate + " " + d.getTime() + '.png', fullPage: fullPage})
|
||||
}
|
||||
await page.emulateMedia('screen')
|
||||
if (program.pdf) await page.pdf({ path: await page.title() + " " + program.emulate + " " + d.getTime() + '.pdf' })
|
||||
console.log(await page.title())
|
||||
if (program.pdf) await page.pdf({ path: t + " " + program.emulate + " " + d.getTime() + '.pdf' })
|
||||
console.log(t)
|
||||
await browser.close()
|
||||
})()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "screenshoteer",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Make screenshots and device emulations form your terminal",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue