feat(Viber - Hide ads): Support latest app target (#5863)

This commit is contained in:
Samo Hribar
2025-09-17 19:51:33 +02:00
committed by GitHub
parent 8502eb8eac
commit e6cce85541
3 changed files with 29 additions and 12 deletions

View File

@@ -1877,4 +1877,3 @@ public final class app/revanced/util/resource/StringResource : app/revanced/util
public final class app/revanced/util/resource/StringResource$Companion {
public final fun fromNode (Lorg/w3c/dom/Node;)Lapp/revanced/util/resource/StringResource;
}

View File

@@ -2,12 +2,6 @@ package app.revanced.patches.viber.ads
import app.revanced.patcher.fingerprint
internal val adsFreeFingerprint = fingerprint {
returns("I")
parameters()
custom { method, classDef ->
classDef.type.contains("com/viber/voip/feature/viberplus") &&
classDef.superclass?.contains("com/viber/voip/core/feature") == true && // Must extend com.viber.voip.core.feature.?
classDef.methods.count() == 1
}
internal val findAdStringFingerprint = fingerprint {
strings("viber_plus_debug_ads_free_flag")
}

View File

@@ -1,17 +1,41 @@
package app.revanced.patches.viber.ads
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
@Suppress("unused")
val hideAdsPatch = bytecodePatch(
name = "Hide Ads",
description = "Hides ad banners between chats.",
) {
compatibleWith("com.viber.voip"("25.9.2.0"))
compatibleWith("com.viber.voip"("25.9.2.0", "26.1.2.0"))
execute {
// Return 1 (true) indicating ads should be disabled.
adsFreeFingerprint.method.returnEarly(1)
val method = findAdStringFingerprint.method
// Find the ads free string index
val stringIndex = findAdStringFingerprint.stringMatches!!.first().index
// Search backwards from the string to find the `new-instance` (TypeReference) instruction
val typeRefIndex = method.indexOfFirstInstructionReversedOrThrow(stringIndex) { this.opcode == Opcode.NEW_INSTANCE }
// Get the class name from the TypeReference
val targetClass = method.getInstruction<ReferenceInstruction>(typeRefIndex).reference as TypeReference
// Patch the ads-free method to always return true
fingerprint {
returns("I")
parameters()
custom { method, classDef ->
classDef == targetClass
}
}.method.returnEarly(1)
}
}