11package me.devsaki.hentoid.activities.sources
22
3+ import android.webkit.WebResourceRequest
34import android.webkit.WebResourceResponse
5+ import android.webkit.WebView
46import androidx.lifecycle.lifecycleScope
57import kotlinx.coroutines.Dispatchers
68import kotlinx.coroutines.launch
@@ -13,10 +15,16 @@ import timber.log.Timber
1315import java.io.IOException
1416
1517private const val DOMAIN_FILTER = " yiffer.xyz"
16- private const val GALLERY_NAME = " c/ [%'\\ w\\ -_\\ .\\ !\\ ,]+"
18+ private const val YIFFER_NAME = " [%'\\ w\\ -_\\ .\\ !\\ ,]+"
1719private val GALLERY_FILTER = arrayOf(
18- " $DOMAIN_FILTER /$GALLERY_NAME $" ,
19- " $DOMAIN_FILTER /$GALLERY_NAME \\ .data$" ,
20+ " $DOMAIN_FILTER /c/$YIFFER_NAME $" ,
21+ " $DOMAIN_FILTER /c/$YIFFER_NAME \\ .data$" ,
22+ )
23+ val RESULTS_FILTER = arrayOf(
24+ " $DOMAIN_FILTER /browse.data" ,
25+ " $DOMAIN_FILTER /root.data" ,
26+ " $DOMAIN_FILTER /_root.data" ,
27+ " $DOMAIN_FILTER /artist/$YIFFER_NAME .data"
2028)
2129private val REMOVABLE_ELEMENTS =
2230 arrayOf($$" $x //a[contains(@href,\" kkbr.ai\" )]/.." , " a[href*='https://fundownun']" )
@@ -31,6 +39,7 @@ class YifferActivity : BaseBrowserActivity() {
3139 val client = YifferWebClient (getStartSite(), GALLERY_FILTER , this )
3240 client.restrictTo(DOMAIN_FILTER )
3341 client.addRemovableElements(* REMOVABLE_ELEMENTS )
42+ client.setResultsUrlPatterns(* RESULTS_FILTER )
3443 return client
3544 }
3645
@@ -40,6 +49,14 @@ class YifferActivity : BaseBrowserActivity() {
4049 activity : BrowserActivity
4150 ) : CustomWebViewClient(site, filter, activity) {
4251
52+ override fun shouldInterceptRequest (
53+ view : WebView ,
54+ request : WebResourceRequest
55+ ): WebResourceResponse ? {
56+ if (isResultsPage(request.url.toString())) onNoResult()
57+ return super .shouldInterceptRequest(view, request)
58+ }
59+
4360 override fun parseResponse (
4461 url : String ,
4562 requestHeaders : Map <String , String >? ,
0 commit comments