Skip to content

Commit

Permalink
Disable transitions to any url other than /translator
Browse files Browse the repository at this point in the history
  • Loading branch information
sakusaku3939 committed Aug 3, 2024
1 parent 7101c5d commit 19f7c0d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ class MyWebViewClient(

var loadFinishedListener: (() -> Unit)? = null

override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean = false
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val url = request?.url.toString()
val regex = Regex("^https://www\\.deepl\\.com/.*/translator.*$")
val isDeepLTranslatorUrl = regex.matches(url)

return !isDeepLTranslatorUrl
}

override fun onPageFinished(view: WebView, url: String) {
if (!isSplashFadeDone) {
Expand Down

0 comments on commit 19f7c0d

Please sign in to comment.