feat(Cricbuzz - Hide ads): Hide Cricbuzz11 UI elements (#5381)

This commit is contained in:
hoodles 2025-07-09 10:47:10 -07:00 committed by GitHub
parent f37482443a
commit a3d47e72e3
11 changed files with 121 additions and 9 deletions

View file

@ -3,24 +3,38 @@ package app.revanced.patches.cricbuzz.ads
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.cricbuzz.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/cricbuzz/ads/HideAdsPatch;"
@Suppress("unused")
val disableAdsPatch = bytecodePatch (
name = "Hide ads",
) {
compatibleWith("com.cricbuzz.android"("6.23.02"))
compatibleWith("com.cricbuzz.android"("6.24.01"))
dependsOn(sharedExtensionPatch)
execute {
userStateSwitchFingerprint.method.apply {
val opcodeIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT_OBJECT)
val register = getInstruction<OneRegisterInstruction>(opcodeIndex).registerA
userStateSwitchFingerprint.method.returnEarly(true)
addInstruction(
opcodeIndex + 1,
"const-string v$register, \"ACTIVE\""
// Remove region-specific Cricbuzz11 elements.
cb11ConstructorFingerprint.method.addInstruction(0, "const/4 p7, 0x0")
getBottomBarFingerprint.method.apply {
val getIndex = indexOfFirstInstructionOrThrow() {
opcode == Opcode.IGET_OBJECT && getReference<FieldReference>()?.name == "bottomBar"
}
val getRegister = getInstruction<TwoRegisterInstruction>(getIndex).registerA
addInstruction(getIndex + 1,
"invoke-static { v$getRegister }, $EXTENSION_CLASS_DESCRIPTOR->filterCb11(Ljava/util/List;)V"
)
}
}

View file

@ -4,6 +4,30 @@ import app.revanced.patcher.fingerprint
import com.android.tools.smali.dexlib2.Opcode
internal val userStateSwitchFingerprint = fingerprint {
strings("key.user.state", "NA")
opcodes(Opcode.SPARSE_SWITCH)
strings("key.user.state", "NA")
}
internal val cb11ConstructorFingerprint = fingerprint {
parameters(
"Ljava/lang/String;",
"Ljava/lang/String;",
"Ljava/lang/String;",
"I",
"Ljava/lang/String;",
"Ljava/lang/String;",
"Z",
"Ljava/lang/String;",
"Ljava/lang/String;",
"L"
)
custom { _, classDef ->
classDef.endsWith("CB11Details;")
}
}
internal val getBottomBarFingerprint = fingerprint {
custom { method, classDef ->
method.name == "getBottomBar" && classDef.endsWith("HomeMenu;")
}
}

View file

@ -0,0 +1,5 @@
package app.revanced.patches.cricbuzz.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch("cricbuzz", applicationInitHook)

View file

@ -0,0 +1,9 @@
package app.revanced.patches.cricbuzz.misc.extension
import app.revanced.patches.shared.misc.extension.extensionHook
internal val applicationInitHook = extensionHook {
custom { method, classDef ->
method.name == "onCreate" && classDef.endsWith("/NyitoActivity;")
}
}