11async function getMangaListByLatest ( page , pageSize ) {
22 const comicsIdUrl = 'https://api.mangadex.org/chapter' ;
33 const url = 'https://api.mangadex.org/manga' ;
4+ const userConfig = window . Rulia . getUserConfig ( ) ;
5+ let language = userConfig . Language ;
6+ if ( ! language ) {
7+ language = '' ;
8+ } else {
9+ language = '&translatedLanguage[]=' + language
10+ }
411 try {
512 const comicsIdRawResponse = await window . Rulia . httpRequest ( {
613 url : comicsIdUrl ,
714 method : 'GET' ,
815 payload : 'limit=' + pageSize +
916 '&offset=' + ( ( page - 1 ) * pageSize ) +
10- '&includes[]=user&includes[]=scanlation_group&includes[]=manga&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&order[readableAt]=desc'
17+ '&includes[]=user&includes[]=scanlation_group&includes[]=manga&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&order[readableAt]=desc' +
18+ language
1119 } ) ;
1220 const comicsIdResponse = JSON . parse ( comicsIdRawResponse ) ;
1321 var comicsIdList = [ ] ;
@@ -127,11 +135,20 @@ async function getMangaData(dataPageUrl) {
127135 const seasonIdMatch = dataPageUrl . match ( seasonIdMatchExp ) ;
128136 const detailUrl = 'https://api.mangadex.org/manga/' + seasonIdMatch [ 1 ] ;
129137 const chapterListUrl = 'https://api.mangadex.org/manga/' + seasonIdMatch [ 1 ] + '/feed' ;
138+ const comicsIdUrl = 'https://api.mangadex.org/manga' ;
139+ const url = 'https://api.mangadex.org/manga' ;
140+ const userConfig = window . Rulia . getUserConfig ( ) ;
141+ let language = userConfig . Language ;
142+ if ( ! language ) {
143+ language = '' ;
144+ } else {
145+ language = '&translatedLanguage[]=' + language
146+ }
130147 try {
131148 const detailRawResponse = await window . Rulia . httpRequest ( {
132149 url : detailUrl ,
133150 method : 'GET' ,
134- payload : 'includes[]=artist&includes[]=author&includes[]=cover_art'
151+ payload : 'includes[]=artist&includes[]=author&includes[]=cover_art' + language
135152 } )
136153 const detailResponse = JSON . parse ( detailRawResponse ) ;
137154 let comicTitle = '' ;
@@ -157,12 +174,20 @@ async function getMangaData(dataPageUrl) {
157174 const chapterListRawResponse = await window . Rulia . httpRequest ( {
158175 url : chapterListUrl ,
159176 method : 'GET' ,
160- payload : 'limit=500&includes[]=scanlation_group&includes[]=user&order[volume]=desc&order[chapter]=desc&offset=0&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic'
177+ payload : 'limit=500&includes[]=scanlation_group&includes[]=user&order[volume]=desc&order[chapter]=desc&offset=0&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic' +
178+ language
161179 } ) ;
162180 const chapterListResponse = JSON . parse ( chapterListRawResponse ) ;
163181 for ( var manga of chapterListResponse . data ) {
182+ let translatedLanguage = manga . attributes . translatedLanguage . charAt ( 0 ) . toUpperCase ( ) + manga . attributes
183+ . translatedLanguage . slice ( 1 ) ;
184+ let title = manga . attributes . title ? '[' + manga . attributes . title + ']' : '' ;
185+ let chapter = manga . attributes . chapter . length === 1 ? '0' + manga . attributes . chapter : manga . attributes
186+ . chapter ;
187+ let updatedAt = new Date ( manga . attributes . updatedAt ) . toISOString ( ) . split ( 'T' ) [ 0 ] . replace ( / - / g, '/' ) ;
164188 var comic = {
165- title : manga . attributes . translatedLanguage + '.' + manga . attributes . chapter ,
189+ title : '[' + translatedLanguage + '][' + chapter + ']' + title + '[' +
190+ updatedAt + ']' ,
166191 url : 'https://mangadex.org/chapter/' + manga . id
167192 }
168193 result . chapterList . push ( comic ) ;
0 commit comments