File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,12 +8,27 @@ class NovelarrowParser extends Parser { // eslint-disable-line no-unused-vars
88 }
99
1010 async getChapterUrls ( dom ) {
11- return [ ...dom . querySelectorAll ( ".jsx-6d23f35167deb67d.space-y-6 a" ) ]
11+ let chapters = [ ...dom . querySelectorAll ( ".jsx-6d23f35167deb67d.space-y-6 a" ) ]
1212 . map ( a => ( {
1313 sourceUrl : a . href ,
1414 title : a . querySelector ( "span.hidden" ) ?. textContent ,
1515 } ) )
1616 . reverse ( ) ;
17+
18+ if ( NovelarrowParser . InitialChapterListMaxLength < chapters . length ) {
19+ return chapters ;
20+ }
21+ return this . fetchChapterListViaRest ( dom ) ;
22+ }
23+
24+ async fetchChapterListViaRest ( dom ) {
25+ let root = dom . baseURI . replace ( "/novel/" , "/chapter/" ) + "/" ;
26+ let restUrl = dom . baseURI . replace ( "/novel/" , "/api-web/novels/" ) + "/chapters?sort=asc" ;
27+ let json = ( await HttpClient . fetchJson ( restUrl ) ) . json ;
28+ return json . items . map ( i => ( {
29+ title : i . chapter_name ,
30+ sourceUrl : root + i . chapter_id ,
31+ } ) ) ;
1732 }
1833
1934 findContent ( dom ) {
@@ -86,3 +101,6 @@ class NovelarrowParser extends Parser { // eslint-disable-line no-unused-vars
86101 return [ ...dom . querySelectorAll ( ".site-reading-copy" ) ] ;
87102 }
88103}
104+
105+ // When initially open ToC page, is pre-loaded with up to 30 chapters
106+ NovelarrowParser . InitialChapterListMaxLength = 30 ;
You can’t perform that action at this time.
0 commit comments