diff --git a/lib/funcPerform.js b/lib/funcPerform.js index 8e3ec32..c61aec2 100644 --- a/lib/funcPerform.js +++ b/lib/funcPerform.js @@ -920,23 +920,14 @@ module.exports = { logger.debug('start screenshot') - if (jobItem.project_id === 21292 && parseInt(jobItem.breakpoint) === 1440 && !page.isClosed()) { - const hasScrollHash = await page.evaluate(() => window.location.hash === '#scroll') - if (hasScrollHash) { - await page.evaluate(() => { - const scrollValue = 230 - window.scrollTo(0, scrollValue) - - if (document.scrollingElement) { - document.scrollingElement.scrollTop = scrollValue - } - - window.dispatchEvent(new Event('scroll', { bubbles: true })) - document.dispatchEvent(new Event('scroll', { bubbles: true })) - }) - await page.waitForTimeout(500) + await safeEval(page, async () => { + if (!document.fonts || typeof document.fonts.ready?.then !== 'function') { + return null } - } + + await document.fonts.ready + await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))) + }, undefined, 'fonts.ready wait (pre-screenshot)') await captureScreenshot(page, filename, isWebkit)