INNER CODE UNIT · TypeScript

autoScroll

linvo-io/linvo-scraper · lib/helpers/autoScroll.ts:4

export async function autoScroll(page: Page) {
  await page.evaluate(
    () =>
      new Promise((resolve) => {
        var scrollTop = -1;
        const interval = setInterval(() => {
          window.scrollBy(0, 100);
          if (document.documentElement.scrollTop !== scrollTop) {
            scrollTop = document.documentElement.scrollTop;
            return false;
          }
          clearInterval(interval);
          resolve(void {});
        }, 150);
      })
  );
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…