From f377e9702ec6877585d0a09ddbcf2a42d60782f7 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 20 Sep 2024 20:22:23 +0530 Subject: [PATCH] feat: remove window scrollDown & scrollUp --- maxun-core/src/browserSide/scraper.js | 40 +-------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/maxun-core/src/browserSide/scraper.js b/maxun-core/src/browserSide/scraper.js index a4b2c19e..79893568 100644 --- a/maxun-core/src/browserSide/scraper.js +++ b/maxun-core/src/browserSide/scraper.js @@ -340,43 +340,5 @@ function scrapableHeuristics(maxCountPerPage = 50, minArea = 20000, scrolls = 3, return results; }; - - window.scrollDown = async function (selector, limit) { - let previousHeight = 0; - let itemsLoaded = 0; - - while (itemsLoaded < limit) { - window.scrollTo(0, document.body.scrollHeight); - await new Promise(resolve => setTimeout(resolve, 1000)); - - const currentHeight = document.body.scrollHeight; - - if (currentHeight === previousHeight) { - break; // No more items to load - } - - previousHeight = currentHeight; - itemsLoaded += document.querySelectorAll(selector).length; - } - } - - window.scrollUp = async function (selector, limit) { - let previousHeight = 0; - let itemsLoaded = 0; - - while (itemsLoaded < limit) { - window.scrollBy(0, -window.innerHeight); - await new Promise(resolve => setTimeout(resolve, 1000)); - - const currentHeight = document.body.scrollHeight; - - if (currentHeight === previousHeight) { - break; // No more items to load - } - - previousHeight = currentHeight; - itemsLoaded += document.querySelectorAll(selector).length; - } - } - + })(window); \ No newline at end of file