@@ -1246,9 +1246,9 @@ export default class Interpreter extends EventEmitter {
12461246 if ( checkLimit ( ) ) return allResults ;
12471247
12481248 let loadMoreCounter = 0 ;
1249- // let previousResultCount = allResults.length;
1250- // let noNewItemsCounter = 0;
1251- // const MAX_NO_NEW_ITEMS = 2 ;
1249+ let previousResultCount = allResults . length ;
1250+ let noNewItemsCounter = 0 ;
1251+ const MAX_NO_NEW_ITEMS = 5 ;
12521252
12531253 while ( true ) {
12541254 if ( this . isAborted ) {
@@ -1332,21 +1332,21 @@ export default class Interpreter extends EventEmitter {
13321332
13331333 await scrapeCurrentPage ( ) ;
13341334
1335- // const currentResultCount = allResults.length;
1336- // const newItemsAdded = currentResultCount > previousResultCount;
1335+ const currentResultCount = allResults . length ;
1336+ const newItemsAdded = currentResultCount > previousResultCount ;
13371337
1338- // if (!newItemsAdded) {
1339- // noNewItemsCounter++;
1340- // debugLog(`No new items added after click (${noNewItemsCounter}/${MAX_NO_NEW_ITEMS})`);
1338+ if ( ! newItemsAdded ) {
1339+ noNewItemsCounter ++ ;
1340+ debugLog ( `No new items added after click (${ noNewItemsCounter } /${ MAX_NO_NEW_ITEMS } )` ) ;
13411341
1342- // if (noNewItemsCounter >= MAX_NO_NEW_ITEMS) {
1343- // debugLog(`Stopping after ${MAX_NO_NEW_ITEMS} clicks with no new items`);
1344- // return allResults;
1345- // }
1346- // } else {
1347- // noNewItemsCounter = 0;
1348- // previousResultCount = currentResultCount;
1349- // }
1342+ if ( noNewItemsCounter >= MAX_NO_NEW_ITEMS ) {
1343+ debugLog ( `Stopping after ${ MAX_NO_NEW_ITEMS } clicks with no new items` ) ;
1344+ return allResults ;
1345+ }
1346+ } else {
1347+ noNewItemsCounter = 0 ;
1348+ previousResultCount = currentResultCount ;
1349+ }
13501350
13511351 if ( checkLimit ( ) ) return allResults ;
13521352
0 commit comments