Emerald: #4836: fix problem 1 for some cases (#4852)

This commit is contained in:
Aria Moradi 2020-11-12 16:39:32 +03:30 committed by GitHub
parent 81a24a8b51
commit df7d63a9b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Emerald'
pkgNameSuffix = 'all.emerald'
extClass = '.EmeraldFactory'
extVersionCode = 5
extVersionCode = 6
libVersion = '1.2'
}

View File

@ -269,6 +269,7 @@ open class Emerald(
val pages = mutableListOf<Page>()
val script = document.select("script").html()
if (script.contains("var images =")) {
val imgJson = JSONObject(script.substringAfter("var images = ").substringBefore(";"))
val imgNames = imgJson.names()
@ -280,7 +281,7 @@ open class Emerald(
pages.add(Page(i, "", imgUrl))
}
}
} else if (script.contains("const server =")) {
} else if (script.contains("const server =")) { // bato.to
val duktape = Duktape.create()
val encryptedServer = script.substringAfter("const server = ").substringBefore(";")
val batojs = duktape.evaluate(script.substringAfter("const batojs = ").substringBefore(";")).toString()
@ -298,7 +299,11 @@ open class Emerald(
} else {
for (i in 0 until imgArray.length()) {
val imgUrl = imgArray.get(i)
pages.add(Page(i, "", "https:${server}$imgUrl"))
if (server.startsWith("http"))
pages.add(Page(i, "", "${server}$imgUrl"))
else
pages.add(Page(i, "", "https:${server}$imgUrl"))
}
}
}