pg: screenshot prep only if needed

This commit is contained in:
Ralf Vogler 2023-05-17 11:35:10 +02:00
parent 8ee63c7a35
commit 368229be09

View file

@ -253,13 +253,16 @@ try {
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' });
await page.click('button[data-type="Game"]'); await page.click('button[data-type="Game"]');
} }
const p = path.resolve(cfg.dir.screenshots, 'prime-gaming', `${filenamify(datetime())}.png`);
// await page.screenshot({ path: p, fullPage: true }); // fullPage does not make a difference since scroll not on body but on some element if (notify_games.length) {
await page.keyboard.press('End'); // scroll to bottom to show all games const p = path.resolve(cfg.dir.screenshots, 'prime-gaming', `${filenamify(datetime())}.png`);
await page.waitForTimeout(1000); // wait for fade in animation // await page.screenshot({ path: p, fullPage: true }); // fullPage does not make a difference since scroll not on body but on some element
const viewportSize = page.viewportSize(); // current viewport size await page.keyboard.press('End'); // scroll to bottom to show all games
await page.setViewportSize({...viewportSize, height: 3000}); // increase height, otherwise element screenshot is cut off at the top and bottom await page.waitForTimeout(1000); // wait for fade in animation
if (notify_games.length) await games.screenshot({ path: p }); // screenshot of all claimed games const viewportSize = page.viewportSize(); // current viewport size
await page.setViewportSize({...viewportSize, height: 3000}); // increase height, otherwise element screenshot is cut off at the top and bottom
await games.screenshot({ path: p }); // screenshot of all claimed games
}
if (cfg.pg_claimdlc) { if (cfg.pg_claimdlc) {
console.log('Trying to claim in-game content...'); console.log('Trying to claim in-game content...');