mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-07 01:51:27 +01:00
feat(BaconReader): Add Fix Redgifs API patch (#5761)
This commit is contained in:
5
extensions/baconreader/build.gradle.kts
Normal file
5
extensions/baconreader/build.gradle.kts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
dependencies {
|
||||||
|
compileOnly(project(":extensions:shared:library"))
|
||||||
|
compileOnly(libs.annotation)
|
||||||
|
compileOnly(libs.okhttp)
|
||||||
|
}
|
||||||
1
extensions/baconreader/src/main/AndroidManifest.xml
Normal file
1
extensions/baconreader/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<manifest/>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.revanced.extension.baconreader;
|
||||||
|
|
||||||
|
import app.revanced.extension.shared.fixes.redgifs.BaseFixRedgifsApiPatch;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noinspection unused
|
||||||
|
*/
|
||||||
|
public class FixRedgifsApiPatch extends BaseFixRedgifsApiPatch {
|
||||||
|
static {
|
||||||
|
INSTANCE = new FixRedgifsApiPatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultUserAgent() {
|
||||||
|
// BaconReader uses a static user agent for Redgifs API calls
|
||||||
|
return "BaconReader";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OkHttpClient install(OkHttpClient.Builder builder) {
|
||||||
|
return builder.addInterceptor(INSTANCE).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -535,6 +535,14 @@ public final class app/revanced/patches/reddit/customclients/baconreader/api/Spo
|
|||||||
public static final fun getSpoofClientPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getSpoofClientPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patches/reddit/customclients/baconreader/fix/redgifs/FixRedgifsApiPatchKt {
|
||||||
|
public static final fun getFixRedgifsApi ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patches/reddit/customclients/baconreader/misc/extension/SharedExtensionPatchKt {
|
||||||
|
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatchKt {
|
public final class app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatchKt {
|
||||||
public static final fun getDisableAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getDisableAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
|
||||||
|
internal val getOkHttpClientFingerprint = fingerprint {
|
||||||
|
returns("Lokhttp3/OkHttpClient;")
|
||||||
|
parameters()
|
||||||
|
custom { method, classDef ->
|
||||||
|
classDef.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager;" && method.name == "getOkhttpClient"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD
|
||||||
|
import app.revanced.patches.reddit.customclients.baconreader.misc.extension.sharedExtensionPatch
|
||||||
|
import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch
|
||||||
|
import app.revanced.util.getReference
|
||||||
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
|
||||||
|
|
||||||
|
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/baconreader/FixRedgifsApiPatch;"
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
val fixRedgifsApi = fixRedgifsApiPatch(
|
||||||
|
extensionPatch = sharedExtensionPatch
|
||||||
|
) {
|
||||||
|
compatibleWith(
|
||||||
|
"com.onelouder.baconreader",
|
||||||
|
"com.onelouder.baconreader.premium",
|
||||||
|
)
|
||||||
|
|
||||||
|
execute {
|
||||||
|
// region Patch Redgifs OkHttp3 client.
|
||||||
|
|
||||||
|
getOkHttpClientFingerprint.method.apply {
|
||||||
|
// Remove conflicting OkHttp interceptors.
|
||||||
|
val originalInterceptorInstallIndex = indexOfFirstInstructionOrThrow {
|
||||||
|
opcode == Opcode.NEW_INSTANCE && getReference<TypeReference>()?.type == "Lcom/onelouder/baconreader/media/gfycat/RedGifsManager\$HeaderInterceptor;"
|
||||||
|
}
|
||||||
|
removeInstructions(originalInterceptorInstallIndex, 5)
|
||||||
|
|
||||||
|
val index = indexOfFirstInstructionOrThrow {
|
||||||
|
val reference = getReference<MethodReference>()
|
||||||
|
reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;"
|
||||||
|
}
|
||||||
|
val register = getInstruction<FiveRegisterInstruction>(index).registerC
|
||||||
|
replaceInstruction(
|
||||||
|
index,
|
||||||
|
"""
|
||||||
|
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->$INSTALL_NEW_CLIENT_METHOD
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package app.revanced.patches.reddit.customclients.baconreader.misc.extension
|
||||||
|
|
||||||
|
import app.revanced.patches.reddit.customclients.baconreader.misc.extension.hooks.initHook
|
||||||
|
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||||
|
|
||||||
|
val sharedExtensionPatch = sharedExtensionPatch("baconreader", initHook)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patches.reddit.customclients.baconreader.misc.extension.hooks
|
||||||
|
|
||||||
|
import app.revanced.patches.shared.misc.extension.extensionHook
|
||||||
|
|
||||||
|
internal val initHook = extensionHook {
|
||||||
|
custom { method, _ ->
|
||||||
|
method.definingClass == "Lcom/onelouder/baconreader/BaconReader;" && method.name == "onCreate"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user