refactor(baconreader): FixRedgifsApiPatch

This commit is contained in:
Pun Butrach
2026-01-12 15:28:50 +07:00
parent 4540e7a484
commit eadc76b161
2 changed files with 13 additions and 10 deletions

View File

@@ -1,11 +1,15 @@
package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs
import app.revanced.patcher.fingerprint
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.definingClass
import app.revanced.patcher.name
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
internal val getOkHttpClientFingerprint = fingerprint {
returns("Lokhttp3/OkHttpClient;")
parameters()
custom { method, classDef ->
classDef.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager;" && method.name == "getOkhttpClient"
}
}
internal val BytecodePatchContext.getOkHttpClientMethod by gettingFirstMutableMethodDeclaratively {
returnType("Lokhttp3/OkHttpClient;")
parameterTypes()
definingClass("Lcom/onelouder/baconreader/media/gfycat/RedGifsManager;")
name("getOkhttpClient")
}

View File

@@ -1,7 +1,6 @@
package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.extensions.removeInstructions
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD
@@ -28,7 +27,7 @@ val fixRedgifsApi = fixRedgifsApiPatch(
apply {
// region Patch Redgifs OkHttp3 client.
getOkHttpClientFingerprint.method.apply {
getOkHttpClientMethod.apply {
// Remove conflicting OkHttp interceptors.
val originalInterceptorInstallIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.NEW_INSTANCE && getReference<TypeReference>()?.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager\$HeaderInterceptor;"