refactor(userscript): thread seriesId through latest-chapter scan

This commit is contained in:
2026-08-03 17:04:19 +07:00
parent 78eaecb119
commit b96caf13e6
2 changed files with 16 additions and 4 deletions
+6 -4
View File
@@ -311,9 +311,11 @@
}
// Highest chapter the site lists, or null when the markup yields nothing.
function computeLatestChapter(site, anchors) {
// seriesId is only consulted by adapters whose pages carry other series'
// chapter links; the rest ignore it.
function computeLatestChapter(site, anchors, seriesId) {
const a = adapterFor(site);
return a ? a.latestChapterFromAnchors(anchors) : null;
return a ? a.latestChapterFromAnchors(anchors, seriesId) : null;
}
function currentSite() {
@@ -834,7 +836,7 @@
if (!existing) return;
applyLatestChapterIfChanged(
existing,
computeLatestChapter(p.site, anchorsFromDocument(document))
computeLatestChapter(p.site, anchorsFromDocument(document), p.seriesId)
);
}
@@ -864,7 +866,7 @@
const res = await fetch(bm.series_url, { credentials: "same-origin" });
if (!res.ok) continue;
const html = await res.text();
const latest = computeLatestChapter(bm.site, anchorsFromHTML(html));
const latest = computeLatestChapter(bm.site, anchorsFromHTML(html), bm.series_id);
await applyLatestChapterIfChanged(state.byKey[bm.key] || bm, latest);
} catch (e) {
/* offline or blocked — try again after the throttle window */