Commit 868197c7 authored by Duhoux Pierre-Louis's avatar Duhoux Pierre-Louis

Fix first chapters list loading on mangarock (CORB issue)

parent 97e15e99
Pipeline #55794314 passed with stages
in 5 minutes and 57 seconds
...@@ -84,9 +84,21 @@ class HandleManga { ...@@ -84,9 +84,21 @@ class HandleManga {
} else { } else {
return Promise.resolve(); return Promise.resolve();
} }
case "loadListChaps":
return this.loadListChaps(message)
} }
} }
/**
* Loads chapters list
* @param {*} message
*/
async loadListChaps(message) {
let impl = await mirrorsImpl.getImpl(message.mirror);
let lst = await impl.getListChaps(message.url)
return Promise.resolve(lst);
}
/** /**
* Search mangas on a mirror from search phrase * Search mangas on a mirror from search phrase
* @param {*} message * @param {*} message
......
...@@ -641,10 +641,21 @@ ...@@ -641,10 +641,21 @@
if (alreadyLoadedListChaps && alreadyLoadedListChaps.length > 0) { if (alreadyLoadedListChaps && alreadyLoadedListChaps.length > 0) {
this.chapters = alreadyLoadedListChaps.map(arr => { return { url: arr[1], title: arr[0] } }) this.chapters = alreadyLoadedListChaps.map(arr => { return { url: arr[1], title: arr[0] } })
} else { } else {
// Change currentMangaURL so no conflict in http over https let list = []
let list = await mirrorImpl.get().getListChaps( if (mirrorImpl.get().fromback && mirrorImpl.get().fromback.includes("chaps")) {
this.pageData.currentMangaURL.replace(/(^\w+:|^)/, '') // we need to load chapters using background page
) list = await browser.runtime.sendMessage({
action: "loadListChaps",
mirror: this.mirror.mirrorName,
url: this.pageData.currentMangaURL,
language: this.pageData.language
});
} else {
// Change currentMangaURL so no conflict in http over https
list = await mirrorImpl.get().getListChaps(
this.pageData.currentMangaURL.replace(/(^\w+:|^)/, '')
)
}
if (list !== undefined && !Array.isArray(list)) { // case of returned list is an object keys are languages and values are list of mangas if (list !== undefined && !Array.isArray(list)) { // case of returned list is an object keys are languages and values are list of mangas
if (list[this.manga.language] && list[this.manga.language].length > 0) { if (list[this.manga.language] && list[this.manga.language].length > 0) {
this.chapters = list[this.manga.language].map(arr => { return { url: arr[1], title: arr[0] } }) this.chapters = list[this.manga.language].map(arr => { return { url: arr[1], title: arr[0] } })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment