From 49b0c484b97d3c5a6afc0c195d5edf47dee84491 Mon Sep 17 00:00:00 2001 From: Rohit Date: Thu, 28 Aug 2025 15:29:14 +0530 Subject: [PATCH] fix: add multiple scroll approach --- maxun-core/src/interpret.ts | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index faa473c2..5b695b3d 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -734,10 +734,22 @@ export default class Interpreter extends EventEmitter { return allResults; } - await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); + await page.evaluate(() => { + const scrollHeight = Math.max( + document.body.scrollHeight, + document.documentElement.scrollHeight + ); + + window.scrollTo(0, scrollHeight); + }); await page.waitForTimeout(2000); - const currentHeight = await page.evaluate(() => document.body.scrollHeight); + const currentHeight = await page.evaluate(() => { + return Math.max( + document.body.scrollHeight, + document.documentElement.scrollHeight + ); + }); const currentResultCount = allResults.length; if (currentResultCount === previousResultCount) { @@ -1024,10 +1036,22 @@ export default class Interpreter extends EventEmitter { // Wait for content to load and check scroll height await page.waitForTimeout(2000); - await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); + await page.evaluate(() => { + const scrollHeight = Math.max( + document.body.scrollHeight, + document.documentElement.scrollHeight + ); + + window.scrollTo(0, scrollHeight); + }); await page.waitForTimeout(2000); - - const currentHeight = await page.evaluate(() => document.body.scrollHeight); + + const currentHeight = await page.evaluate(() => { + return Math.max( + document.body.scrollHeight, + document.documentElement.scrollHeight + ); + }); const heightChanged = currentHeight !== previousHeight; previousHeight = currentHeight;