chore: lint

This commit is contained in:
karishmas6
2024-08-18 22:19:24 +05:30
parent 3771de92ca
commit 1260730e56

View File

@@ -382,34 +382,34 @@ export default class Interpreter extends EventEmitter {
switch (config.pagination.type) { switch (config.pagination.type) {
case 'scrollDown': case 'scrollDown':
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
// Wait for potential lazy-loaded content // Wait for potential lazy-loaded content
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
// Check if new content was loaded // Check if new content was loaded
const currentHeight = await page.evaluate(() => document.body.scrollHeight); const currentHeight = await page.evaluate(() => document.body.scrollHeight);
if (currentHeight === previousHeight) { if (currentHeight === previousHeight) {
// No new content loaded, exit loop // No new content loaded, exit loop
return allResults; return allResults;
} }
previousHeight = currentHeight; previousHeight = currentHeight;
break; break;
case 'scrollUp': case 'scrollUp':
await page.evaluate(() => window.scrollUp(config.listSelector, config.limit)); await page.evaluate(() => window.scrollUp(config.listSelector, config.limit));
break; break;
case 'clickNext': case 'clickNext':
const nextButton = await page.$(config.pagination.selector); const nextButton = await page.$(config.pagination.selector);
if (!nextButton) { if (!nextButton) {
return allResults; // No more pages return allResults; // No more pages
} }
// Capture the current URL to check if it changes after clicking next // Capture the current URL to check if it changes after clicking next
const currentURL = page.url(); const currentURL = page.url();
await Promise.all([ await Promise.all([
nextButton.click(), nextButton.click(),
page.waitForNavigation({ waitUntil: 'load' }) // Wait for page navigation page.waitForNavigation({ waitUntil: 'load' }) // Wait for page navigation
]); ]);
break; break;
case 'clickLoadMore': case 'clickLoadMore':
const loadMoreButton = await page.$(config.pagination.selector); const loadMoreButton = await page.$(config.pagination.selector);
if (!loadMoreButton) { if (!loadMoreButton) {