From cf1609a4294a658d3c192335a9793b3c0db8ac55 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 7 Feb 2021 16:19:13 -0500 Subject: [PATCH] Massage user agent string from WebView a bit more --- .../java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt index 7f10186ce..e19cc6945 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt @@ -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 {