Skip to content

fix(english/ao3): scope byline, stats and summary, classify failures - #2958

Closed
JKJapona wants to merge 1 commit into
lnreader:masterfrom
JKJapona:fix/ao3-parsing
Closed

JKJapona wants to merge 1 commit into
lnreader:masterfrom
JKJapona:fix/ao3-parsing

Conversation

@JKJapona

@JKJapona JKJapona commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes four parsing defects in the AO3 plugin (version 1.1.0 → 1.2.0).

Before After
Author every a[rel="author"] on the page — a translated fic listed 58 authors .byline a[rel="author"], joined with , ; falls back to the byline text for anonymous works
Stats dd.stats li a.tag matches nothing — the block was always empty dl.stats dt/dd pairs
Summary every blockquote.userstuff (up to 3) — author's notes leaked in .summary blockquote.userstuff
Blocked pages a login page / adult interstitial / challenge served with HTTP 200 parsed as Untitled plus one blank chapter classified, then thrown as the matching PluginError

Details

  • Author. AO3 renders one a[rel="author"] per creator in .byline, but also links the authors of translations and related works inside the notes. Scoping to the byline fixes the 58-name case and leaves co-written works correct (InfiniteTickingClock37, Spiritmander13).
  • Stats. The old selector no longer exists in AO3's markup; the values come from dl.stats dt/dd.
  • Summary. .summary blockquote.userstuff is the only summary container; the other blockquotes on the page are notes.
  • Failures. AO3 answers a restricted work, the adult interstitial and a Cloudflare challenge with HTTP 200. fetchPage now classifies every response into ok / adult-gate / login-required / challenge / rate-limited / not-found and throws the matching canonical PluginError (AuthRequired, Captcha, RateLimited, NovelNotFound, InvalidResponse), so a restricted work says "log in" instead of showing nothing. The login page is identified by two signals — no #chapters and (restricted=true or a /users/login final URL) — so a normal page that merely links to restricted=true still parses. There is a test for that case.

Tests

scripts/test-ao3.js — 15 tests, no network:

node --test scripts/test-ao3.js

The fixtures in scripts/fixtures/ao3/ are real pages captured as a guest (~206 KB; <style>/<script> stripped, nothing reads them). They cover a 58-author work, a co-written work, an anonymous work, a one-shot, a restricted login page, the adult interstitial and a 188-chapter index. The test builds the plugin with esbuild and stubs only @libs/fetch; @libs/pluginError is compiled for real, so the asserted error codes are the production ones. Not wired into package.json, matching scripts/test-royalroad.js.

Verification

Check Result
node --test scripts/test-ao3.js 15/15 pass
Prettier / ESLint clean
tsc --noEmit -p tsconfig.json no errors in ao3.ts (108 pre-existing repo-wide)
node scripts/live-check-plugin.js plugins/english/ao3.ts INCONCLUSIVE — HTTP 429, exit 0

On the live check: AO3 sits behind Cloudflare, which rejects a non-browser TLS fingerprint regardless of headers. In the same minute Chromium got 200 (with and without cookies) while Node fetch got 429 and curl 429/503. check:plugin therefore cannot validate this plugin from a server network; the fixture tests are the real signal. This is also why rate limit and challenge map to INCONCLUSIVE rather than FAIL.

- author: read the byline (one author link per creator) and fall back to its
  text, so translated works no longer show up to 58 names and anonymous works
  are no longer blank
- stats: read dl.stats dt/dd pairs; the old dd.stats li a.tag matches nothing
- summary: scope to .summary blockquote.userstuff, not every blockquote
- classify responses: a guest login page, the adult interstitial, a Cloudflare
  challenge and a 429 all arrive as usable-looking responses today, so a
  restricted work parsed as an Untitled novel with a blank chapter. They now
  throw the matching PluginError with an actionable message.
- add offline fixture tests in scripts/test-ao3.js (pnpm check:plugin cannot
  reach AO3 from a non-browser TLS stack)

version: 1.2.0
@JKJapona JKJapona closed this Dec 1, 2026
@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · Reject unhandled HTTP failures before merging so server errors cannot become blank chapters or incorrect chapter lists.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect AO3 reading and discovery flows, but stay within that plugin.

Reject unhandled HTTP failures before merging so server errors cannot become blank chapters or incorrect chapter lists.

Findings

  1. P1 Server errors become blank chapters ▶

Summary

Updates the AO3 plugin to 1.2.0.

  • AO3 work details come from the sections that describe the work.
  • AO3 gates and failed requests now produce clear plugin errors.

Acknowledged behavior: JKJapona explicitly intends HTTP 503 to be reported as a bot check, as stated in the PR description and tests.

Reviews (1) · Last reviewed commit: "fix(english/ao3): scope byline, stats an..." · Reviewed by Greptile

Comment thread plugins/english/ao3.ts
return { kind: 'adult-gate', html };
}

return { kind: 'ok', html };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Server errors become blank chapters

classifyPage accepts HTTP failures such as 500 and 502 as ok when their bodies lack the listed markers. fetchApi does not reject HTTP errors, so a plain “Bad Gateway” page reaches the parsers. parseChapter returns an empty string, while a failed chapter index makes parseNovel replace the chapter list with one fallback entry.

The previous checkResponse rejected these responses. Keep the specific classifications, then reject any remaining response where res.ok is false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant