Fix japscan (dynamic page loading) (#14109)
* Fix japscan * Update extVersionCode
This commit is contained in:
parent
c088dfcc6f
commit
2d56d12797
@ -6,7 +6,7 @@ ext {
|
||||
extName = 'Japscan'
|
||||
pkgNameSuffix = 'fr.japscan'
|
||||
extClass = '.Japscan'
|
||||
extVersionCode = 32
|
||||
extVersionCode = 33
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -11,6 +11,7 @@ import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebResourceResponse
|
||||
@ -351,7 +352,7 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||
val zjs = client.newCall(GET(baseUrl + zjsurl, headers)).execute().body!!.string()
|
||||
Log.d("japscan", "webtoon, netdumping initiated")
|
||||
val pagesElement = document.getElementById("pages")
|
||||
val pagecount = pagesElement.getElementsByTag("option").size
|
||||
var pagecount = pagesElement.getElementsByTag("option").size
|
||||
val pages = ArrayList<Page>()
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val checkNew = ArrayList<String>(pagecount)
|
||||
@ -376,6 +377,21 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
||||
webview.settings.domStorageEnabled = true
|
||||
webview.settings.userAgentString = webview.settings.userAgentString.replace("Mobile", "eliboM").replace("Android", "diordnA")
|
||||
webview.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView, url: String?) {
|
||||
if (pagecount === 0) {
|
||||
Log.d("japscan", "dynamic page count detected, loading it through JS")
|
||||
super.onPageFinished(view, url)
|
||||
view.evaluateJavascript(
|
||||
"(function() { return document.getElementById('pages').length; })();",
|
||||
object : ValueCallback<String> {
|
||||
override fun onReceiveValue(numberOfPages: String?) {
|
||||
pagecount = numberOfPages!!.toInt()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldInterceptRequest(
|
||||
view: WebView,
|
||||
request: WebResourceRequest
|
||||
|
Loading…
x
Reference in New Issue
Block a user