fix page list (#3564)
This commit is contained in:
parent
927897c78b
commit
b6c20bf147
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Japscan'
|
extName = 'Japscan'
|
||||||
extClass = '.Japscan'
|
extClass = '.Japscan'
|
||||||
extVersionCode = 47
|
extVersionCode = 48
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -5,11 +5,10 @@ import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Base64
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
import android.webkit.WebView
|
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.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
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.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.security.MessageDigest
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.crypto.Cipher
|
|
||||||
import javax.crypto.spec.IvParameterSpec
|
|
||||||
import javax.crypto.spec.SecretKeySpec
|
|
||||||
|
|
||||||
class Japscan : ConfigurableSource, ParsedHttpSource() {
|
class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||||
|
|
||||||
|
@ -234,27 +229,18 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val interfaceName = randomString()
|
val interfaceName = randomString()
|
||||||
val zjsElement = document.selectFirst("script[src*=/zjs/]")
|
document.body().prepend(
|
||||||
?: 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(
|
|
||||||
"""
|
"""
|
||||||
<script>
|
<script>
|
||||||
const _parse = JSON.parse;
|
const _atob = atob;
|
||||||
|
atob = function(arg) {
|
||||||
JSON.parse = function(...args) {
|
let data = _atob(arg)
|
||||||
window.$interfaceName.passPayload(args[0]);
|
window.$interfaceName.passPayload(data);
|
||||||
return _parse(...args);
|
return data;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
)
|
)
|
||||||
minDocBody.appendChild(zjsElement)
|
|
||||||
|
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
val latch = CountDownLatch(1)
|
val latch = CountDownLatch(1)
|
||||||
|
@ -270,16 +256,26 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||||
innerWv.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
|
innerWv.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
|
||||||
innerWv.addJavascriptInterface(jsInterface, interfaceName)
|
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(
|
innerWv.loadDataWithBaseURL(
|
||||||
document.location(),
|
document.location(),
|
||||||
minDoc.outerHtml(),
|
document.outerHtml(),
|
||||||
"text/html",
|
"text/html",
|
||||||
"UTF-8",
|
"UTF-8",
|
||||||
null,
|
null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
latch.await(5, TimeUnit.SECONDS)
|
latch.await(10, TimeUnit.SECONDS)
|
||||||
handler.post { webView?.destroy() }
|
handler.post { webView?.destroy() }
|
||||||
|
|
||||||
if (latch.count == 1L) {
|
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 = ""
|
override fun imageUrlParse(document: Document): String = ""
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
|
@ -355,10 +332,14 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
@Suppress("UNUSED")
|
@Suppress("UNUSED")
|
||||||
fun passPayload(rawData: String) {
|
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 }
|
images = data["imagesLink"]!!.jsonArray.map { it.jsonPrimitive.content }
|
||||||
latch.countDown()
|
latch.countDown()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue