feat(userscript): stamp and filter by kind in the manga script

This commit is contained in:
2026-08-06 03:22:28 +07:00
parent d465028443
commit 51fcd8732b
2 changed files with 31 additions and 2 deletions
+16 -2
View File
@@ -29,6 +29,10 @@
// with its own prefix, so the two never share a cache, a queue or a panel.
const STORE_PREFIX = "bmgr:manga:";
// Which library this script's rows belong to. The novel script is a separate
// install that declares "novel"; the backend keeps whichever it is told.
const LIBRARY = "manga";
// Safe in Bromite's isolated world: the page's own JS cannot read these.
const CACHE_KEY = STORE_PREFIX + "cache";
@@ -518,7 +522,9 @@
}
function setList(list) {
state.list = Array.isArray(list) ? list : [];
// GET /bookmarks answers with every library; this panel owns one of them,
// and the cache must not hold rows it can never show.
state.list = (Array.isArray(list) ? list : []).filter((b) => kindOf(b) === LIBRARY);
reindex();
saveCache(state.list);
}
@@ -543,6 +549,12 @@
return b.status || "reading";
}
// A list cached by an older version has no kind field, and a row the server
// defaulted has "manga" — both mean the same thing here.
function kindOf(b) {
return b.kind || "manga";
}
// ============================================================
// Retry queue
//
@@ -827,6 +839,7 @@
const bm = {
key: key,
site: p.site,
kind: LIBRARY,
series_id: p.seriesId,
title: p.title || (existing && existing.title) || p.seriesId,
series_url: p.seriesUrl || (existing && existing.series_url) || "",
@@ -849,6 +862,7 @@
const bm = Object.assign({}, existing, {
key: key,
site: p.site,
kind: LIBRARY,
series_id: p.seriesId,
title: existing.title || p.title || p.seriesId,
series_url: existing.series_url || p.seriesUrl || "",
@@ -1799,7 +1813,7 @@
// Exposes pure logic only — see userscript/test/logic.test.js.
// ============================================================
if (typeof window === "undefined" && typeof module === "object" && module.exports) {
module.exports = { stripBuildHash, comixSeriesId, asura, demonic, comix, kagane, anchorsFromHTML, statusOf };
module.exports = { stripBuildHash, comixSeriesId, asura, demonic, comix, kagane, anchorsFromHTML, statusOf, kindOf };
}
// ============================================================