Bato.to: Fix no pages found error (#12035)

* Bato.to: Fix no pages found error

* Bump extension version

* Update Changelog
This commit is contained in:
zyrif 2022-06-01 16:58:18 +06:00 committed by GitHub
parent b4df51d652
commit 1f591f4e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,9 @@
## 1.2.23
### Fix
* Update pageListParse logic to handle website changes
## 1.2.22
### Features

View File

@ -6,7 +6,7 @@ ext {
extName = 'Bato.to'
pkgNameSuffix = 'all.batoto'
extClass = '.BatoToFactory'
extVersionCode = 22
extVersionCode = 23
isNsfw = true
}

View File

@ -489,6 +489,35 @@ open class BatoTo(
pages.add(Page(i, imageUrl = if (server.startsWith("http")) "${server}$imgUrl" else "https:${server}$imgUrl"))
}
}
} else if (script.contains("const imgHttpLis = ") && script.contains("const batoWord = ") && script.contains(
"const batoPass = "
)
) {
val duktape = Duktape.create()
val imgHttpLis = json.parseToJsonElement(
script.substringAfter("const imgHttpLis = ").substringBefore(";")
).jsonArray
val batoWord = script.substringAfter("const batoWord = ").substringBefore(";")
val batoPass =
duktape.evaluate(script.substringAfter("const batoPass = ").substringBefore(";"))
.toString()
val input =
cryptoJS + "CryptoJS.AES.decrypt($batoWord, \"$batoPass\").toString(CryptoJS.enc.Utf8);"
val imgWordLis = json.parseToJsonElement(duktape.evaluate(input).toString()).jsonArray
duktape.close()
if (imgHttpLis.size == imgWordLis.size) {
imgHttpLis.forEachIndexed { i: Int, item ->
val imageUrl =
"${item.jsonPrimitive.content}?${imgWordLis.get(i).jsonPrimitive.content}"
pages.add(
Page(
i,
imageUrl = imageUrl
)
)
}
}
}
return pages