Skip to content

Commit a42c98f

Browse files
authored
feat(Cricbuzz - Hide ads): Hide Cricbuzz11 UI elements (#5381)
1 parent 501f19a commit a42c98f

File tree

11 files changed

+121
-9
lines changed

11 files changed

+121
-9
lines changed

extensions/cricbuzz/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies {
2+
compileOnly(project(":extensions:shared:library"))
3+
compileOnly(project(":extensions:cricbuzz:stub"))
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest/>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package app.revanced.extension.cricbuzz.ads;
2+
3+
import com.cricbuzz.android.data.rest.model.BottomBar;
4+
import java.util.List;
5+
import java.util.Iterator;
6+
import app.revanced.extension.shared.Logger;
7+
8+
@SuppressWarnings("unused")
9+
public class HideAdsPatch {
10+
11+
/**
12+
* Injection point.
13+
*/
14+
public static void filterCb11(List<BottomBar> list) {
15+
try {
16+
Iterator<BottomBar> iterator = list.iterator();
17+
while (iterator.hasNext()) {
18+
BottomBar bar = iterator.next();
19+
if (bar.getName().equals("Cricbuzz11")) {
20+
Logger.printInfo(() -> "Removing Cricbuzz11 bar: " + bar);
21+
iterator.remove();
22+
}
23+
}
24+
} catch (Exception ex) {
25+
Logger.printException(() -> "filterCb11 failure", ex);
26+
}
27+
}
28+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
alias(libs.plugins.android.library)
3+
}
4+
5+
android {
6+
namespace = "app.revanced.extension"
7+
compileSdk = 34
8+
9+
defaultConfig {
10+
minSdk = 21
11+
}
12+
13+
compileOptions {
14+
sourceCompatibility = JavaVersion.VERSION_11
15+
targetCompatibility = JavaVersion.VERSION_11
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest/>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.cricbuzz.android.data.rest.model;
2+
3+
public final class BottomBar {
4+
public final String getName() { throw new UnsupportedOperationException(); }
5+
}

patches/api/patches.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ public final class app/revanced/patches/cricbuzz/ads/DisableAdsPatchKt {
168168
public static final fun getDisableAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
169169
}
170170

171+
public final class app/revanced/patches/cricbuzz/misc/extension/ExtensionPatchKt {
172+
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
173+
}
174+
171175
public final class app/revanced/patches/crunchyroll/ads/HideAdsPatchKt {
172176
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
173177
}

patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/DisableAdsPatch.kt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,38 @@ package app.revanced.patches.cricbuzz.ads
33
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
44
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
55
import app.revanced.patcher.patch.bytecodePatch
6+
import app.revanced.patches.cricbuzz.misc.extension.sharedExtensionPatch
7+
import app.revanced.util.getReference
68
import app.revanced.util.indexOfFirstInstructionOrThrow
9+
import app.revanced.util.returnEarly
710
import com.android.tools.smali.dexlib2.Opcode
8-
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
11+
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
12+
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
13+
14+
private const val EXTENSION_CLASS_DESCRIPTOR =
15+
"Lapp/revanced/extension/cricbuzz/ads/HideAdsPatch;"
916

1017
@Suppress("unused")
1118
val disableAdsPatch = bytecodePatch (
1219
name = "Hide ads",
1320
) {
14-
compatibleWith("com.cricbuzz.android"("6.23.02"))
21+
compatibleWith("com.cricbuzz.android"("6.24.01"))
22+
23+
dependsOn(sharedExtensionPatch)
1524

1625
execute {
17-
userStateSwitchFingerprint.method.apply {
18-
val opcodeIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT_OBJECT)
19-
val register = getInstruction<OneRegisterInstruction>(opcodeIndex).registerA
26+
userStateSwitchFingerprint.method.returnEarly(true)
27+
28+
// Remove region-specific Cricbuzz11 elements.
29+
cb11ConstructorFingerprint.method.addInstruction(0, "const/4 p7, 0x0")
30+
getBottomBarFingerprint.method.apply {
31+
val getIndex = indexOfFirstInstructionOrThrow() {
32+
opcode == Opcode.IGET_OBJECT && getReference<FieldReference>()?.name == "bottomBar"
33+
}
34+
val getRegister = getInstruction<TwoRegisterInstruction>(getIndex).registerA
2035

21-
addInstruction(
22-
opcodeIndex + 1,
23-
"const-string v$register, \"ACTIVE\""
36+
addInstruction(getIndex + 1,
37+
"invoke-static { v$getRegister }, $EXTENSION_CLASS_DESCRIPTOR->filterCb11(Ljava/util/List;)V"
2438
)
2539
}
2640
}

patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/Fingerprints.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@ import app.revanced.patcher.fingerprint
44
import com.android.tools.smali.dexlib2.Opcode
55

66
internal val userStateSwitchFingerprint = fingerprint {
7-
strings("key.user.state", "NA")
87
opcodes(Opcode.SPARSE_SWITCH)
8+
strings("key.user.state", "NA")
99
}
10+
11+
internal val cb11ConstructorFingerprint = fingerprint {
12+
parameters(
13+
"Ljava/lang/String;",
14+
"Ljava/lang/String;",
15+
"Ljava/lang/String;",
16+
"I",
17+
"Ljava/lang/String;",
18+
"Ljava/lang/String;",
19+
"Z",
20+
"Ljava/lang/String;",
21+
"Ljava/lang/String;",
22+
"L"
23+
)
24+
custom { _, classDef ->
25+
classDef.endsWith("CB11Details;")
26+
}
27+
}
28+
29+
internal val getBottomBarFingerprint = fingerprint {
30+
custom { method, classDef ->
31+
method.name == "getBottomBar" && classDef.endsWith("HomeMenu;")
32+
}
33+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package app.revanced.patches.cricbuzz.misc.extension
2+
3+
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
4+
5+
val sharedExtensionPatch = sharedExtensionPatch("cricbuzz", applicationInitHook)

0 commit comments

Comments
 (0)