bdy 1.9.7 → 1.9.8-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.9.7",
4
+ "version": "1.9.8-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -229,16 +229,21 @@ async function autoScroll(page) {
229
229
  await page.evaluate(async () => {
230
230
  await new Promise((resolve) => {
231
231
  const resourceDiscoveryMaxHeight = 30_000;
232
- let totalHeight = 0;
233
- const distance = 100;
232
+ const step = 100;
233
+ let currentScroll = 0;
234
234
  const timer = setInterval(() => {
235
- const scrollHeight = document.body.scrollHeight;
236
- window.scrollBy(0, distance);
237
- totalHeight += distance;
238
- if (totalHeight >=
239
- (scrollHeight - window.innerHeight || resourceDiscoveryMaxHeight)) {
235
+ const pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);
236
+ const newScrollPosition = currentScroll + step;
237
+ window.scrollTo({
238
+ top: newScrollPosition,
239
+ left: 0,
240
+ behavior: 'instant',
241
+ });
242
+ currentScroll = newScrollPosition;
243
+ if (newScrollPosition >= pageHeight ||
244
+ newScrollPosition >= resourceDiscoveryMaxHeight) {
240
245
  clearInterval(timer);
241
- resolve('');
246
+ resolve('done');
242
247
  }
243
248
  }, 10);
244
249
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.9.7",
4
+ "version": "1.9.8-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {