Repository navigation
feat(english/asurascans): add Asura Scans novels source - #2647
Conversation
|
| apiUrl = 'https://api.asurascans.com/api'; | ||
| version = '1.0.0'; | ||
|
|
||
| hideLocked = storage.get('hideLocked'); |
There was a problem hiding this comment.
There was a problem hiding this comment.
Fixed in aafeba6: parseNovel now reads storage.get('hideLocked') on each call instead of a class field. In the playground I set the key in plugin storage and re-fetched Black Badger without reloading. It showed 100 chapters (50 🔒) with the key unset, 50 (0 🔒) with it on, and 100 (50 🔒) with it off again.
(Reply and fix by an AI agent, Claude.)
| return $('body').html() || ''; | ||
| } | ||
|
|
||
| resolveUrl = (path: string) => `${this.site}/${path}`; |
There was a problem hiding this comment.
resolveUrl prefixes absolute URLs with this.site. EPUB export calls this method with sourceNovel.cover, so an absolute cover URL becomes https://asurascans.com/https://.... This also breaks the absolute defaultCover used when a novel has no cover. Return absolute URLs unchanged before joining relative paths.
| resolveUrl = (path: string) => `${this.site}/${path}`; | |
| resolveUrl = (path: string) => | |
| /^https?:\/\//i.test(path) | |
| ? path | |
| : `${this.site}/${path.replace(/^\/+/, '')}`; |
There was a problem hiding this comment.
Fixed in aafeba6 using your suggestion: absolute http(s) URLs are returned unchanged, and relative paths are joined to this.site with leading slashes stripped. A local fixture check confirms a CDN cover URL passes through unchanged and that novels/<slug> and /novels/<slug>/chapter/1 resolve to https://asurascans.com/....
(Reply and fix by an AI agent, Claude.)
| $('p') | ||
| .filter((_, el) => $(el).text().includes('Back to homepage')) | ||
| .remove(); |
There was a problem hiding this comment.
The navigation cleanup deletes every paragraph containing Back to homepage, anywhere in the chapter. That can also delete real prose containing those words. Limit the removal to the known trailing navigation block, and add a fixture that keeps those words inside an ordinary paragraph.
There was a problem hiding this comment.
Fixed in aafeba6: cleanup moved to cleanChapter, which now removes only trailing paragraphs that contain both Back to homepage and Reporting chapter:, the leaked nav/report-dialog block. The repo has no unit-test suite, so I ran a local fixture script against the bundled plugin rather than committing a test. The real Shadow Slave ch. 1 payload drops only that last paragraph (97 → 96). It keeps a mid-chapter paragraph containing Back to homepage, a final prose paragraph containing it, and a nav-like paragraph that is not last.
(Reply and fix by an AI agent, Claude.)
Read the hideLocked setting on each parseNovel call, return absolute URLs unchanged from resolveUrl, and only strip the trailing leaked navigation paragraph from chapter text.
Adds an English source for the Asura Scans novels section (https://asurascans.com/novels), using the site's public JSON API at
api.asurascans.com.Closes #2636
How it was tested
npm run check:plugin -- plugins/english/asurascans.ts: PASS (popular 20 novels, search 1 result, parseNovel 3160 chapters, parseChapter 11143 chars)npx prettier --check plugins/english/asurascans.tsandnpx eslint plugins/english/asurascans.tsare clean, andnpm run build:compilepasses.npm run lintstill fails on 3 errors in other plugins that are already onmaster.Checklist
1.0.0)type(scope): description(e.g.feat(<generator>): add new source)An AI agent (Claude) wrote this PR and ran the tests above. No human has reviewed it yet.