Marc Kupietz | 02d582a | 2023-10-09 20:11:52 +0200 | [diff] [blame] | 1 | #!/usr/bin/env node |
| 2 | |
| 3 | const puppeteer = require('puppeteer'); |
| 4 | |
| 5 | function delay(time) { |
| 6 | return new Promise(function (resolve) { |
| 7 | setTimeout(resolve, time) |
| 8 | }); |
| 9 | } |
| 10 | |
| 11 | (async () => { |
| 12 | const browser = await puppeteer.launch({ |
| 13 | headless: "new", |
| 14 | args: ['--no-sandbox'], |
| 15 | defaultViewport: { |
Marc Kupietz | c7249f9 | 2023-10-10 07:16:50 +0200 | [diff] [blame^] | 16 | width: 1920, |
| 17 | height: 1080, |
Marc Kupietz | 02d582a | 2023-10-09 20:11:52 +0200 | [diff] [blame] | 18 | isLandscape: true, |
Marc Kupietz | c7249f9 | 2023-10-10 07:16:50 +0200 | [diff] [blame^] | 19 | deviceScaleFactor: 0.5 |
Marc Kupietz | 02d582a | 2023-10-09 20:11:52 +0200 | [diff] [blame] | 20 | } |
| 21 | }); |
| 22 | |
| 23 | const page = await browser.newPage(); |
| 24 | |
| 25 | for (var i = 2; i < process.argv.length; i += 2) { |
| 26 | await page.goto(process.argv[i], { waitUntil: 'networkidle2' }); |
| 27 | await delay(1000); |
| 28 | await page.screenshot({ path: process.argv[i+1] }); |
| 29 | } |
| 30 | |
| 31 | await browser.close(); |
| 32 | })(); |