mirror of
https://github.com/vladocar/screenshoteer.git
synced 2024-11-16 17:08:33 +01:00
Added basic HTTP authentication
This commit is contained in:
parent
a0e425353a
commit
166f6658cb
1 changed files with 5 additions and 0 deletions
5
index.js
5
index.js
|
@ -15,6 +15,7 @@ program
|
|||
.option('--h, [h]', 'height')
|
||||
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
|
||||
.option('--el, [el]', 'element css selector')
|
||||
.option('--auth, [auth]', 'Basic HTTP authentication')
|
||||
.parse(process.argv);
|
||||
|
||||
if (program.url) urlvalue = program.url
|
||||
|
@ -40,6 +41,10 @@ console.log(fullPage);
|
|||
const d = new Date()
|
||||
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]);
|
||||
if (program.auth) {
|
||||
const [username, password] = program.auth.split(':');
|
||||
await page.authenticate({username:username, password:password});
|
||||
}
|
||||
await page.goto(urlvalue)
|
||||
const title = await page.title()
|
||||
const t = title.replace(/[/\\?%*:|"<>]/g, '-')
|
||||
|
|
Loading…
Reference in a new issue