fix: pagination detection all types
This commit is contained in:
@@ -2124,20 +2124,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const infiniteScrollScore = (options && options.disableScrollDetection)
|
const infiniteScrollScore = (options && options.disableScrollDetection)
|
||||||
? 0
|
? 0
|
||||||
: detectInfiniteScrollScore();
|
: detectInfiniteScrollScore();
|
||||||
const hasStrongInfiniteScrollSignals = infiniteScrollScore >= 8;
|
const hasStrongInfiniteScrollSignals = infiniteScrollScore >= 8;
|
||||||
const hasMediumInfiniteScrollSignals = infiniteScrollScore >= 5 && infiniteScrollScore < 8;
|
const hasMediumInfiniteScrollSignals = infiniteScrollScore >= 5 && infiniteScrollScore < 8;
|
||||||
|
|
||||||
if (hasStrongInfiniteScrollSignals) {
|
|
||||||
const confidence = infiniteScrollScore >= 12 ? 'high' : infiniteScrollScore >= 10 ? 'medium' : 'low';
|
|
||||||
return {
|
|
||||||
type: 'scrollDown',
|
|
||||||
selector: null,
|
|
||||||
confidence: confidence
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loadMoreButton && loadMoreScore >= 15) {
|
if (loadMoreButton && loadMoreScore >= 15) {
|
||||||
const selector = generatePaginationSelector(loadMoreButton);
|
const selector = generatePaginationSelector(loadMoreButton);
|
||||||
return {
|
return {
|
||||||
@@ -2147,7 +2138,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextButton && nextButtonScore >= 15 && !hasMediumInfiniteScrollSignals) {
|
if (nextButton && nextButtonScore >= 15) {
|
||||||
const selector = generatePaginationSelector(nextButton);
|
const selector = generatePaginationSelector(nextButton);
|
||||||
return {
|
return {
|
||||||
type: 'clickNext',
|
type: 'clickNext',
|
||||||
@@ -2156,6 +2147,35 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasStrongInfiniteScrollSignals) {
|
||||||
|
const confidence = infiniteScrollScore >= 12 ? 'high' : infiniteScrollScore >= 10 ? 'medium' : 'low';
|
||||||
|
return {
|
||||||
|
type: 'scrollDown',
|
||||||
|
selector: null,
|
||||||
|
confidence: confidence
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadMoreButton && loadMoreScore >= 10) {
|
||||||
|
const selector = generatePaginationSelector(loadMoreButton);
|
||||||
|
const confidence = 'medium';
|
||||||
|
return {
|
||||||
|
type: 'clickLoadMore',
|
||||||
|
selector: selector,
|
||||||
|
confidence: confidence
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextButton && nextButtonScore >= 10) {
|
||||||
|
const selector = generatePaginationSelector(nextButton);
|
||||||
|
const confidence = 'medium';
|
||||||
|
return {
|
||||||
|
type: 'clickNext',
|
||||||
|
selector: selector,
|
||||||
|
confidence: confidence
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (hasMediumInfiniteScrollSignals) {
|
if (hasMediumInfiniteScrollSignals) {
|
||||||
const confidence = infiniteScrollScore >= 7 ? 'medium' : 'low';
|
const confidence = infiniteScrollScore >= 7 ? 'medium' : 'low';
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ export class SelectorValidator {
|
|||||||
const win = window as any;
|
const win = window as any;
|
||||||
|
|
||||||
if (typeof win.autoDetectPagination === 'function') {
|
if (typeof win.autoDetectPagination === 'function') {
|
||||||
const result = win.autoDetectPagination(selector, { disableScrollDetection: false });
|
const result = win.autoDetectPagination(selector);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
console.error('autoDetectPagination function not found!');
|
console.error('autoDetectPagination function not found!');
|
||||||
|
|||||||
Reference in New Issue
Block a user