fix page list (#3564)
This commit is contained in:
parent
927897c78b
commit
b6c20bf147
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
extName = 'Japscan'
|
||||
extClass = '.Japscan'
|
||||
extVersionCode = 47
|
||||
extVersionCode = 48
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
|
|
@ -5,11 +5,10 @@ import android.app.Application
|
|||
import android.content.SharedPreferences
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Base64
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.webkit.WebView
|
||||
import eu.kanade.tachiyomi.extension.R
|
||||
import android.webkit.WebViewClient
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||
|
@ -37,14 +36,10 @@ import org.jsoup.nodes.Element
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.security.MessageDigest
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||
|
||||
|
@ -234,27 +229,18 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
|||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val interfaceName = randomString()
|
||||
val zjsElement = document.selectFirst("script[src*=/zjs/]")
|
||||
?: throw Exception("ZJS not found")
|
||||
val dataElement = document.select(selector("dLqEgOqeqp/72OXDYKI5lA=="))
|
||||
?: throw Exception("Chapter data not found")
|
||||
val minDoc = Document.createShell(document.location())
|
||||
val minDocBody = minDoc.body()
|
||||
|
||||
minDocBody.appendChildren(dataElement)
|
||||
minDocBody.append(
|
||||
document.body().prepend(
|
||||
"""
|
||||
<script>
|
||||
const _parse = JSON.parse;
|
||||
|
||||
JSON.parse = function(...args) {
|
||||
window.$interfaceName.passPayload(args[0]);
|
||||
return _parse(...args);
|
||||
const _atob = atob;
|
||||
atob = function(arg) {
|
||||
let data = _atob(arg)
|
||||
window.$interfaceName.passPayload(data);
|
||||
return data;
|
||||
};
|
||||
</script>
|
||||
""".trimIndent(),
|
||||
)
|
||||
minDocBody.appendChild(zjsElement)
|
||||
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val latch = CountDownLatch(1)
|
||||
|
@ -270,16 +256,26 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
|||
innerWv.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
|
||||
innerWv.addJavascriptInterface(jsInterface, interfaceName)
|
||||
|
||||
innerWv.webViewClient = object : WebViewClient() {
|
||||
override fun shouldOverrideUrlLoading(
|
||||
view: WebView?,
|
||||
url: String?,
|
||||
): Boolean {
|
||||
url ?: return true
|
||||
return !url.contains("/zjs/")
|
||||
}
|
||||
}
|
||||
|
||||
innerWv.loadDataWithBaseURL(
|
||||
document.location(),
|
||||
minDoc.outerHtml(),
|
||||
document.outerHtml(),
|
||||
"text/html",
|
||||
"UTF-8",
|
||||
null,
|
||||
)
|
||||
}
|
||||
|
||||
latch.await(5, TimeUnit.SECONDS)
|
||||
latch.await(10, TimeUnit.SECONDS)
|
||||
handler.post { webView?.destroy() }
|
||||
|
||||
if (latch.count == 1L) {
|
||||
|
@ -296,25 +292,6 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun selector(encrypted: String): String {
|
||||
val secretKey = run {
|
||||
val crypto = ((R.mipmap.ic_launcher ushr 87895464) * (456123 ushr 42) - 16 / 4 * -3)
|
||||
.toString()
|
||||
.toByteArray(Charsets.UTF_32BE)
|
||||
|
||||
MessageDigest.getInstance("SHA-1")
|
||||
.digest(crypto)
|
||||
.take(16)
|
||||
}.toByteArray()
|
||||
|
||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||
val key = SecretKeySpec(secretKey, "AES")
|
||||
val iv = IvParameterSpec(Base64.decode("totally not some plaintxt".toByteArray(), Base64.DEFAULT))
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, iv)
|
||||
|
||||
return String(cipher.doFinal(Base64.decode(encrypted, Base64.DEFAULT)))
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document): String = ""
|
||||
|
||||
// Filters
|
||||
|
@ -355,10 +332,14 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
|||
@JavascriptInterface
|
||||
@Suppress("UNUSED")
|
||||
fun passPayload(rawData: String) {
|
||||
val data = json.parseToJsonElement(rawData).jsonObject
|
||||
try {
|
||||
val data = json.parseToJsonElement(rawData).jsonObject
|
||||
|
||||
images = data["imagesLink"]!!.jsonArray.map { it.jsonPrimitive.content }
|
||||
latch.countDown()
|
||||
images = data["imagesLink"]!!.jsonArray.map { it.jsonPrimitive.content }
|
||||
latch.countDown()
|
||||
} catch (_: Exception) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue