fix: restore Riwyat covers and chapter content (#2465) - #2466
Conversation
cenele.com migrated to a custom Madara child theme (nhv-*) that dropped the classic selectors. parseChapter's unguarded Cheerio `||` chain short-circuited to an empty selection (truthy) returning '', and parseNovel lost its name/cover/metadata selectors. - parseChapter: length-guarded container chain (.text-left -> .text-right -> .reading-content -> .entry-content -> .c-blog-post...) with loud throws (container not found / content empty) instead of returning '' (lnreader#2462 pattern) - parseNovel: h1.nhv-novel-title and img.wp-post-image fallbacks - parseNovel: existence-guarded nhv-* metadata block (genres/status/author) - riwyat: versionIncrements 1 (plugin 2.2.1) and new customJs stripping [data-nosnippet]/style/script/promo injection - tests: regression-2465.mjs + fixtures (14 checks; RED 7 -> GREEN 14) Generated multisrc files are gitignored; run node plugins/multisrc/generate-multisrc-plugins.js before testing.
| let failures = 0; | ||
| const check = (label, cond, detail) => { | ||
| const ok = !!cond; | ||
| console.log(`${ok ? 'PASS' : 'FAIL'} ${label} ${ok ? '' : '-- ' + detail}`); |
There was a problem hiding this comment.
eslint: this new .mjs file is outside the globals-bearing config block in eslint.config.js (files: ['/*.{ts,tsx,mts,cts,js,cjs}']), so it lints against the base config with no Node globals. Result: 6 errors — no-undef 'console' (lines 34, 53, 192), no-undef 'process' (57, 195), and @typescript-eslint/no-unused-vars for the unused 'init' fetch-stub param (80). Local npm run lint reports these and lint.yml (reviewdog, fail_on_error:false) will annotate the PR. Suggested fix: add a flat-config block to eslint.config.js: '{ files: ["/*.mjs"], languageOptions: { globals: { ...globals.node } } }' (globals is already imported) and drop the unused init parameter from the fetch stub (extra arguments are ignored by the caller).
Verification report: build, typecheck, lint, tests (builder-bob)Verified point: commit Result summary
Details
CI status noteThis PR is cross-repository (head fork RibatTRW/lnreader-plugins) and draft. The three workflow runs tied to 631dca9 are in |
What
Riwyat (
https://cenele.com/) broke: detail pages showed the default "cover not available" image and an empty novel name, chapters showed "no content available".cenele.com migrated to a custom Madara child theme (class prefix
nhv-*, "novel" theme) that dropped the classic Madara selectors the shared template depends on. The template'sparseChapterchains Cheerio selections with||. An empty Cheerio selection is truthy, so the first missing selector (.text-left) short-circuits the whole chain to an empty selection →html()→''(the empty chapters).parseNovellost its name (.post-title h1) and cover (.summary_image > a > img) selectors too.Why / how
.text-left→.text-right→.reading-content→.entry-content→.c-blog-post > div > div:nth-child(2). When nothing matches or parsed content is empty it now throws a descriptive error instead of returning''(same accepted loud-error pattern as the merged upstream fix NovelFire Empty Chapter fix #2462 for NovelFire)..reading-contentprecedes.entry-contentbecause on this theme.entry-contentwraps prev/next nav + a report widget (2.6 KB chrome).h1.nhv-novel-title.img.wp-post-image.nhv-*block (genres/status/author): only fires when the theme's elements exist, so classic Madara / NovelHub sources are untouched.versionIncrements: 1(plugin 2.2.1, so cached installs refetch) and a newcustomJsstripping[data-nosnippet],style,script,input,.nhv-reader-store-promo(the old selector matched zero elements; the theme now injects one promo blockquote after every paragraph plus a VIP store ad).Tests
Fixture-backed, deterministic, no network:
tests/regression-2465.mjs+tests/fixtures/2465/(saved live-site pages).'')defaultCover)'')Completed)'')'')Baseline: 7 FAILING → after fix: 14/14 ALL GREEN.
Live check (
node scripts/live-check-plugin.js "plugins/arabic/Riwyat[madara].ts"): popularNovels PASS 12 · searchNovels PASS 5 · parseNovel PASS 3 chapters · parseChapter PASS 10,323 chars.Gates
npx prettier --checkclean ontemplate.ts,sources.json,regression-2465.mjsnpx eslint plugins/multisrc/madara/template.tscleannpx tsc --noEmit: zero new errors vs base (repo-wide 1289 pre-existing errors in gitignored generated files; production tsconfig is transpile-only withnoCheck: true)plugins/*/*[madara].tsare gitignored (regenerate before testing)Closes #2465
Review note
eslint.config.jsalso gains Node globals for**/*.mjs. That file is outside the issue's change list. It stays: it is the smallest change that lets the committedtests/regression-2465.mjsrun clean under lint. No plugin runtime code depends on it.Automated contribution via Hermes Agent.