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

@@ -0,0 +1,4 @@
dependencies {
compileOnly(project(":extensions:shared:library"))
compileOnly(project(":extensions:cricbuzz:stub"))
}

View File

@@ -0,0 +1 @@
<manifest/>

View File

@@ -0,0 +1,28 @@
package app.revanced.extension.cricbuzz.ads;
import com.cricbuzz.android.data.rest.model.BottomBar;
import java.util.List;
import java.util.Iterator;
import app.revanced.extension.shared.Logger;
@SuppressWarnings("unused")
public class HideAdsPatch {
/**
* Injection point.
*/
public static void filterCb11(List<BottomBar> list) {
try {
Iterator<BottomBar> iterator = list.iterator();
while (iterator.hasNext()) {
BottomBar bar = iterator.next();
if (bar.getName().equals("Cricbuzz11")) {
Logger.printInfo(() -> "Removing Cricbuzz11 bar: " + bar);
iterator.remove();
}
}
} catch (Exception ex) {
Logger.printException(() -> "filterCb11 failure", ex);
}
}
}

View File

@@ -0,0 +1,17 @@
plugins {
alias(libs.plugins.android.library)
}
android {
namespace = "app.revanced.extension"
compileSdk = 34
defaultConfig {
minSdk = 21
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

View File

@@ -0,0 +1 @@
<manifest/>

View File

@@ -0,0 +1,5 @@
package com.cricbuzz.android.data.rest.model;
public final class BottomBar {
public final String getName() { throw new UnsupportedOperationException(); }
}

View File

@@ -168,6 +168,10 @@ public final class app/revanced/patches/cricbuzz/ads/DisableAdsPatchKt {
public static final fun getDisableAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/cricbuzz/misc/extension/ExtensionPatchKt {
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/crunchyroll/ads/HideAdsPatchKt {
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

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;")
}
}