WebViewResolver

class WebViewResolver(val interceptUrl: Regex, val additionalUrls: List<Regex> = emptyList(), val userAgent: String? = USER_AGENT, val useOkhttp: Boolean = true, val script: String? = null, val scriptCallback: (String) -> Unit? = null, val timeout: Long = DEFAULT_TIMEOUT) : Interceptor

When used as Interceptor additionalUrls cannot be returned, use WebViewResolver(...).resolveUsingWebView(...)

Parameters

interceptUrl

will stop the WebView when reaching this url.

additionalUrls

this will make resolveUsingWebView also return all other requests matching the list of Regex.

userAgent

if null then will use the default user agent

useOkhttp

will try to use the okhttp client as much as possible, but this might cause some requests to fail. Disable for cloudflare.

script

pass custom js to execute

scriptCallback

will be called with the result from custom js

timeout

close webview after timeout

Constructors

Link copied to clipboard
constructor(interceptUrl: Regex, additionalUrls: List<Regex> = emptyList(), userAgent: String? = USER_AGENT, useOkhttp: Boolean = true, script: String? = null, scriptCallback: (String) -> Unit? = null)
constructor(interceptUrl: Regex, additionalUrls: List<Regex> = emptyList(), userAgent: String? = USER_AGENT, useOkhttp: Boolean = true)
constructor(interceptUrl: Regex, additionalUrls: List<Regex> = emptyList(), userAgent: String? = USER_AGENT, useOkhttp: Boolean = true, script: String? = null, scriptCallback: (String) -> Unit? = null, timeout: Long = DEFAULT_TIMEOUT)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val script: String? = null
Link copied to clipboard
val scriptCallback: (String) -> Unit? = null
Link copied to clipboard
Link copied to clipboard
val useOkhttp: Boolean = true
Link copied to clipboard

Functions

Link copied to clipboard
open override fun intercept(chain: Interceptor.Chain): Response
Link copied to clipboard
suspend fun resolveUsingWebView(request: Request, requestCallBack: (Request) -> Boolean = { false }): Pair<Request?, List<Request>>
suspend fun resolveUsingWebView(url: String, referer: String? = null, method: String = "GET", requestCallBack: (Request) -> Boolean = { false }): Pair<Request?, List<Request>>