diff --git a/dist/jhs-enhance.user.js b/dist/jhs-enhance.user.js index e88a9a3..1408392 100644 --- a/dist/jhs-enhance.user.js +++ b/dist/jhs-enhance.user.js @@ -3329,9 +3329,6 @@ ${value}\r const nextLink = document.querySelector(selector.nextPageSelector); this.nextUrl = null == nextLink ? void 0 : nextLink.href; this.hasMore = !!this.nextUrl; - setTimeout((() => { - this.checkLoad(); - }), 1e3); this.hasMore || this.setState("waterfall-no-more", "已经到底了"); } async loadNextPage() { @@ -3403,7 +3400,9 @@ ${value}\r clog.error("加载失败:", e); this.setState("waterfall-error", "加载失败,点击重试"); } finally { - this.isLoading = false; + setTimeout((() => { + this.isLoading = false; + }), 600); } } checkScrollPosition() { @@ -3420,8 +3419,10 @@ ${value}\r } } checkLoad() { - if (!this.loader) return; - this.loader.getBoundingClientRect().top < window.innerHeight + this.preloadDistance && this.loadNextPage().then(); + if (!this.loader || this.isLoading || !this.hasMore) return; + if (window.scrollY < 100) return; + const triggerDistance = 200; + this.loader.getBoundingClientRect().top < window.innerHeight + triggerDistance && this.loadNextPage().then(); } async shouldDisablePaging() { if (!window.isListPage) return true; diff --git a/src/plugins/auto-page.js b/src/plugins/auto-page.js index c7c75e3..cc0db62 100644 --- a/src/plugins/auto-page.js +++ b/src/plugins/auto-page.js @@ -55,9 +55,6 @@ class AutoPagePlugin extends BasePlugin { const nextLink = document.querySelector(selector.nextPageSelector); this.nextUrl = null == nextLink ? void 0 : nextLink.href; this.hasMore = !!this.nextUrl; - setTimeout((() => { - this.checkLoad(); - }), 1e3); this.hasMore || this.setState("waterfall-no-more", "已经到底了"); } async loadNextPage() { @@ -128,7 +125,9 @@ class AutoPagePlugin extends BasePlugin { clog.error("加载失败:", e); this.setState("waterfall-error", "加载失败,点击重试"); } finally { - this.isLoading = !1; + setTimeout((() => { + this.isLoading = !1; + }), 600); } } checkScrollPosition() { @@ -145,8 +144,10 @@ class AutoPagePlugin extends BasePlugin { } } checkLoad() { - if (!this.loader) return; - this.loader.getBoundingClientRect().top < window.innerHeight + this.preloadDistance && this.loadNextPage().then(); + if (!this.loader || this.isLoading || !this.hasMore) return; + if (window.scrollY < 100) return; + const triggerDistance = 200; + this.loader.getBoundingClientRect().top < window.innerHeight + triggerDistance && this.loadNextPage().then(); } async shouldDisablePaging() { if (!window.isListPage) return !0;