pull/46/head
kunfei 5 years ago
parent c5dd8738b6
commit 2861a0c4b4
  1. 18
      app/src/main/java/io/legado/app/help/http/AjaxWebView.kt
  2. 1
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -10,7 +10,6 @@ import android.text.TextUtils
import android.webkit.* import android.webkit.*
import io.legado.app.App import io.legado.app.App
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import java.util.*
class AjaxWebView { class AjaxWebView {
@ -99,7 +98,6 @@ class AjaxWebView {
var cookieStore: CookieStore? = null var cookieStore: CookieStore? = null
var sourceRegex: String? = null var sourceRegex: String? = null
var javaScript: String? = null var javaScript: String? = null
private var audioSuffixList: List<String>? = null
val userAgent: String? val userAgent: String?
get() = this.headerMap?.get("User-Agent") get() = this.headerMap?.get("User-Agent")
@ -122,16 +120,6 @@ class AjaxWebView {
javaScript = null javaScript = null
} }
fun getAudioSuffixList(): List<String>? {
if (audioSuffixList == null) {
audioSuffixList = if (isSniff) {
sourceRegex?.split("\\|\\|".toRegex())
} else {
Collections.emptyList()
}
}
return audioSuffixList
}
} }
class HtmlWebViewClient( class HtmlWebViewClient(
@ -186,12 +174,10 @@ class AjaxWebView {
) : WebViewClient() { ) : WebViewClient() {
override fun onLoadResource(view: WebView, url: String) { override fun onLoadResource(view: WebView, url: String) {
val suffixList = params.getAudioSuffixList() params.sourceRegex?.let {
for (suffix in suffixList!!) { if (url.matches(it.toRegex())) {
if (!TextUtils.isEmpty(suffix) && url.contains(suffix)) {
handler.obtainMessage(MSG_SUCCESS, url) handler.obtainMessage(MSG_SUCCESS, url)
.sendToTarget() .sendToTarget()
break
} }
} }
} }

@ -292,6 +292,7 @@ class AnalyzeUrl(
suspend fun getResultByWebView(tag: String): String { suspend fun getResultByWebView(tag: String): String {
val params = AjaxWebView.AjaxParams(tag) val params = AjaxWebView.AjaxParams(tag)
params.url = url params.url = url
params.headerMap = headerMap
params.requestMethod = method params.requestMethod = method
params.javaScript = webViewJs params.javaScript = webViewJs
params.sourceRegex = sourceRegex params.sourceRegex = sourceRegex

Loading…
Cancel
Save