a4da2e2f00
The lightnovelworld chapter branch no longer derives the Series address by string-manipulating the chapter path: on ~7% of novels the Chapter Slug diverges from the Series slug and the derived address 404s on every Poll. The identity now comes from the page's own a[aria-label='All Chapter'] pointer (breadcrumb's second crumb as fallback), validated as a lightnovelworld.net /novel/<slug>/ address; no pointer resolves to type: other. The Chapter Slug rides on the detected page object only (chapterSlug; null on a series page) and is written to no store, for the stale-row repair in #90. Harness: document.querySelector now answers attribute selectors with an element exposing getAttribute (attrEls table, cleared by reset()). AGENTS.md records that the Series address is discovered, not derived.
6.6 KiB
6.6 KiB
Guidance for OpenCode (and Claude Code) working under userscript/. See root AGENTS.md for the project-wide architecture diagram, hard constraints, and design system.
Userscript structure (single IIFE, manga-bookmark.user.js)
- Site adapters — one per host,
detect(location, document)return pagetype+ IDs. Identify type/IDs from URL regex (most stable); pulltitlefromog:title(or the page heading where a site ships no og: tags), not CSS classes. No adapter reads a cover: the backend acquires, stores and serves every Cover from its own origin (ADR-0007), the wire'scoveris already an address on our origin, andapiPutstrips anycoveroff an outgoing body. - API client —
apiGet/apiPut/apiDeletewith bearer header;localStoragekeybmgr:manga:cachefor instant render + offline fallback. - Progress logic — auto-upsert
last_chapteronly whenchapterNum >= stored last_chapter_num(re-reading old chapters must not regress progress; unparseable -> set current). Manual panel override forces any value. - Retry queue — every write go through
pushBookmark/pushDelete, so failed mutation park inlocalStorage(bmgr:manga:queue) and replayed on next navigation, reconnect, orrefresh(). Entries are markers ({key, op, sendStatus, attempts}), never payloads — body read from cache at send time, so one entry per key give ordering and coalescing for free.sendStatusis sticky: while archive pending, later writes to that key keep carrying bucket, which stop successful in-between write from silently un-archiving series.refresh()drains before it fetches and overlays anything still pending, so list never flaps. 400 drops entry, 401 abort pass and keep queue, and transient failures retry to cap of 10. Latest-chapter writes deliberately stay out of queue. Seedocs/superpowers/specs/2026-07-27-offline-retry-queue-design.md. - UI — rendered inside Shadow DOM root to isolate from site CSS
(critical on mobile). Three tabs (All / Favourites / Archived) and row of
link chips to web UI and both manga sites;
WEB_BASEsits in CONFIG block next toAPI_BASE. FAB is7 × 44edge tab whose hit area widened to28 × 72by invisible#hitchild;#fabmust keeptouch-action: noneand must not regainoverflow: hidden. Sincetouch-actionresolved at gesture start, strip can't be both browser-scrolled and script-dragged, somakeDraggablesplits by intent: swipe from#hitscrolls viawindow.scrollBy, hold ofARM_MSarms reposition drag, visible sliver drags with no hold. Seedocs/superpowers/specs/2026-07-28-edge-tab-hitbox-design.md. - SPA navigation — Asura is Astro, client-routed on comic/chapter pages: patch
history.pushState/replaceState+ listenpopstate, re-rundetect()on URL change so auto-update fire without reload. Demonic uses classic reloads (initialdocument-idlerun suffice).
Live URL shapes (verified 2026-07-26, may drift — re-check against live pages before trust)
- asurascans.com: series
/comics/<slug>(slug carries trailing site-wide build-hash suffix, e.g.-059befe1, that rotates on every redeploy), chapter/comics/<slug>/chapter/<n>.seriesIdmust strip hash (/-[0-9a-f]{8}$/,stripBuildHashin userscript,asuraBuildHashin backend); URLs keep full slug — stale-hash URLs 302 to current ones. Astro-rendered; chapter links present in raw server HTML. - demonicscans.org: series
/manga/<slug>(slug may URL-encode punctuation, e.g.%2527for'), chapter/title/<slug>/chapter/<n>/<page>(olderchaptered.php?manga=<id>&chapter=<n>form still exists as redirect, what series-page chapter-list anchors link through). Encodings (incl. triple-encoded punctuation like%25252D) identical on /manga/ and /title/ pages, so decode-once seriesIds match — verified 2026-07-28. - comix.to: series
/title/<id>-<slug>, chapter/title/<id>-<slug>/<uploadId>-chapter-<n>. Only the leading<id>is identity — the slug re-renders when a series is renamed (comixSeriesId). An SPA that never rewritesog:title: the server-rendered head keeps whatever document loaded first, so on a cold loadog:titleis the homepage's "Comix — Read Comics online for free" and after an in-page hop it is the previous series' name.document.titleis the one thing client routing does update, so titles come from there, with the chapter page's" · Ch.<n>"tail stripped. It publishes noog:imageeither, which is one of the reasons cover acquisition moved to the backend. - kagane.to: series
/series/<uuid>, reader/series/<uuid>/reader/<bookUuid>. Reader URLs carry no chapter number, so the number comes out ofog:title. Two shapes exist:"<Series> - Chapter <n>[ - Episode <n>]"and, for volume-numbered series,"<Series> - Volume <v> Chapter <n>"with no episode name — both must yield a bare series title, or the volume tail lands in the bookmark's title. Its covers are challenge- and CORP-protected, so nothing outside kagane.to can load one directly; the panel renders the backend's own cover address like every other Site. Behind a Cloudflare JS challenge, so the backend polls it through the headless browser. - novelfull.com (novel script): series
/<slug>.html, chapter/<slug>/chapter-<n>[-<title-slug>].html. Noog:*tags at all — title fromh3.title(series) ora.truyen-title(chapter); the script reads no cover. Behind a Cloudflare JS challenge no TLS fingerprint clears, so the backend polls it through the headless browser. - lightnovelworld.net (novel script): series
/novel/<slug>/, chapter/<slug>-chapter-<n>/— flat, at the site root. The chapter path's slug is a Chapter Slug, not an identity: the Series address is read off the page'sa[aria-label='All Chapter'](fallback: the BreadcrumbList's second crumb), and a Series may publish under several Chapter Slugs. A chapter page with no pointer resolves toother, so no Bookmark is offered.h1.entry-titleis the clean title on a series page and<Title> Chapter <n>on a chapter page. Its series page lists every chapter with an absolute href, so the backend polls it with the plain TLS client.
Second script: novel-bookmark.user.js
A copy of the manga script with two adapters, LIBRARY = "novel" and
STORE_PREFIX = "bmgr:novel:". No migration loop (this script has no previous
installation to carry keys over from). Installed alongside the manga script;
both write to the same backend with the same LIBRARY column discriminating
them.