Fix auto captcha opening when you dont have the option enabled (temp fix)

This commit is contained in:
Jobobby04 2020-07-24 12:36:20 -04:00
parent f3b6855684
commit a311a3b497
2 changed files with 8 additions and 6 deletions

View File

@ -1,8 +1,11 @@
package exh.patch package exh.patch
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
typealias EHInterceptor = (request: Request, response: Response, sourceId: Long) -> Response typealias EHInterceptor = (request: Request, response: Response, sourceId: Long) -> Response
@ -16,10 +19,9 @@ fun OkHttpClient.Builder.injectPatches(sourceIdProducer: () -> Long): OkHttpClie
} }
fun findAndApplyPatches(sourceId: Long): EHInterceptor { fun findAndApplyPatches(sourceId: Long): EHInterceptor {
return ( // TODO make it so captcha doesnt auto open in manga eden while applying universal interceptors
(EH_INTERCEPTORS[sourceId] ?: emptyList()) + return if (Injekt.get<PreferencesHelper>().eh_autoSolveCaptchas().get()) ((EH_INTERCEPTORS[sourceId] ?: emptyList()) + (EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList())).merge()
(EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList()) else (EH_INTERCEPTORS[sourceId] ?: emptyList()).merge()
).merge()
} }
fun List<EHInterceptor>.merge(): EHInterceptor { fun List<EHInterceptor>.merge(): EHInterceptor {

View File

@ -51,12 +51,12 @@ class BrowserActionActivity : AppCompatActivity() {
private var validateCurrentLoopId: String? = null private var validateCurrentLoopId: String? = null
private var strictValidationStartTime: Long? = null private var strictValidationStartTime: Long? = null
lateinit var credentialsObservable: Observable<String> private lateinit var credentialsObservable: Observable<String>
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(eu.kanade.tachiyomi.R.layout.eh_activity_captcha) setContentView(R.layout.eh_activity_captcha)
val sourceId = intent.getLongExtra(SOURCE_ID_EXTRA, -1) val sourceId = intent.getLongExtra(SOURCE_ID_EXTRA, -1)
val originalSource = if (sourceId != -1L) sourceManager.get(sourceId) else null val originalSource = if (sourceId != -1L) sourceManager.get(sourceId) else null