Add comix.to and kagane.to support #13
@@ -919,10 +919,11 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything else is only learned by fetching a series page. Same-origin
|
// Everything else is only learned by fetching a series page — or, where the
|
||||||
// only: these requests carry the session that gets us past the site's bot
|
// site offers one, its JSON API. Same-origin only: these requests carry the
|
||||||
// checks, which a request to the other site (or from a server) would not.
|
// session that gets us past the site's bot checks, which a request to the
|
||||||
// One series per navigation keeps it indistinguishable from browsing.
|
// other site (or from a server) would not. A few series per navigation keeps
|
||||||
|
// it indistinguishable from browsing.
|
||||||
async function backgroundRefreshLatest() {
|
async function backgroundRefreshLatest() {
|
||||||
const site = currentSite();
|
const site = currentSite();
|
||||||
if (!site) return;
|
if (!site) return;
|
||||||
@@ -937,15 +938,21 @@
|
|||||||
.slice(0, LATEST_CHECK_BATCH);
|
.slice(0, LATEST_CHECK_BATCH);
|
||||||
if (due.length === 0) return;
|
if (due.length === 0) return;
|
||||||
|
|
||||||
|
const adapter = adapterFor(site);
|
||||||
for (const bm of due) {
|
for (const bm of due) {
|
||||||
// Recorded even when the fetch fails, so a broken series is retried on
|
// Recorded even when the fetch fails, so a broken series is retried on
|
||||||
// the next throttle window rather than on every single page load.
|
// the next throttle window rather than on every single page load.
|
||||||
checked[bm.key] = Date.now();
|
checked[bm.key] = Date.now();
|
||||||
try {
|
try {
|
||||||
|
let latest;
|
||||||
|
if (adapter && adapter.latestChapterFromApi) {
|
||||||
|
latest = await adapter.latestChapterFromApi(bm.series_id);
|
||||||
|
} else {
|
||||||
const res = await fetch(bm.series_url, { credentials: "same-origin" });
|
const res = await fetch(bm.series_url, { credentials: "same-origin" });
|
||||||
if (!res.ok) continue;
|
if (!res.ok) continue;
|
||||||
const html = await res.text();
|
const html = await res.text();
|
||||||
const latest = computeLatestChapter(bm.site, anchorsFromHTML(html), bm.series_id);
|
latest = computeLatestChapter(bm.site, anchorsFromHTML(html), bm.series_id);
|
||||||
|
}
|
||||||
await applyLatestChapterIfChanged(state.byKey[bm.key] || bm, latest);
|
await applyLatestChapterIfChanged(state.byKey[bm.key] || bm, latest);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
/* offline or blocked — try again after the throttle window */
|
/* offline or blocked — try again after the throttle window */
|
||||||
|
|||||||
Reference in New Issue
Block a user