Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit 5beafb3

Browse files
authored
Merge pull request #24 from dertasiu/master
Standarize and pad with zeroes the filename of the pages
2 parents 0f6b0b6 + f22c9e8 commit 5beafb3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

plugins/mangadex/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,19 @@ function selectChapter(id) {
167167
function nextPage() {
168168
const page = parseInt(mango.storage('page'));
169169
const atHome = JSON.parse(mango.storage('atHomeData'));
170-
const filename = atHome.chapter.data[page]
171-
mango.storage('page', (page + 1).toString());
170+
const filename = atHome.chapter.data[page];
172171
if (!filename) return JSON.stringify({});
173172

173+
//Get the number of digits of pages
174+
const len = atHome.chapter.data.length.toString().length;
175+
//Pad the page number with zeroes depending of the number of pages
176+
const pageNum = Array(Math.max(len - String(page + 1).length + 1, 0)).join(0) + (page + 1);
177+
178+
const finalFilename = pageNum + '.' + filename.split('.')[filename.split('.').length -1];
179+
mango.storage('page', (page + 1).toString());
180+
174181
return JSON.stringify({
175182
url: atHome.baseUrl + '/data/' + atHome.chapter.hash + '/' + filename,
176-
filename: filename,
183+
filename: finalFilename,
177184
});
178185
}

0 commit comments

Comments
 (0)