mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Massage user agent string from WebView a bit more
This commit is contained in:
parent
3aeac7e7b5
commit
cf1609a429
@ -10,10 +10,6 @@ import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import timber.log.Timber
|
||||
|
||||
object WebViewUtil {
|
||||
val WEBVIEW_UA_VERSION_REGEX by lazy {
|
||||
Regex(""".*Chrome/(\d+)\..*""")
|
||||
}
|
||||
|
||||
var DEFAULT_USER_AGENT: String = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
||||
private set
|
||||
|
||||
@ -31,6 +27,8 @@ object WebViewUtil {
|
||||
DEFAULT_USER_AGENT = WebView(context)
|
||||
.getDefaultUserAgentString()
|
||||
.replace("; wv", "")
|
||||
.replace(" Build\\/.+?\\)".toRegex(), ")")
|
||||
.replace("Version/.*? ".toRegex(), "")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
@ -59,7 +57,7 @@ fun WebView.setDefaultSettings() {
|
||||
}
|
||||
|
||||
private fun WebView.getWebViewMajorVersion(): Int {
|
||||
val uaRegexMatch = WebViewUtil.WEBVIEW_UA_VERSION_REGEX.matchEntire(getDefaultUserAgentString())
|
||||
val uaRegexMatch = """.*Chrome/(\d+)\..*""".toRegex().matchEntire(getDefaultUserAgentString())
|
||||
return if (uaRegexMatch != null && uaRegexMatch.groupValues.size > 1) {
|
||||
uaRegexMatch.groupValues[1].toInt()
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user