From 1fe3a523e99ccfe556d88800686e34ac6ed77b2c Mon Sep 17 00:00:00 2001 From: 1fexd <58902674+1fexd@users.noreply.github.com> Date: Sun, 6 Oct 2024 01:19:39 +0200 Subject: [PATCH] feat(Willhaben): Add `Hide ads` patch (#3740) --- api/revanced-patches.api | 6 ++++ .../patches/willhaben/ads/HideAdsPatch.kt | 28 +++++++++++++++++++ .../ads/fingerprints/AdResolverFingerprint.kt | 17 +++++++++++ .../WHAdViewInjectorFingerprint.kt | 15 ++++++++++ 4 files changed, 66 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/AdResolverFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/WHAdViewInjectorFingerprint.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index ad04ff075e..5ebfa2f71e 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -1520,6 +1520,12 @@ public final class app/revanced/patches/warnwetter/misc/promocode/PromoCodeUnloc public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/willhaben/ads/HideAdsPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/willhaben/ads/HideAdsPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/windyapp/misc/unlockpro/UnlockProPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/windyapp/misc/unlockpro/UnlockProPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt new file mode 100644 index 0000000000..2bf94f2c3e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt @@ -0,0 +1,28 @@ +package app.revanced.patches.willhaben.ads + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.willhaben.ads.fingerprints.AdResolverFingerprint +import app.revanced.patches.willhaben.ads.fingerprints.WHAdViewInjectorFingerprint +import app.revanced.util.returnEarly + +@Patch( + name = "Hide ads", + description = "Hides all in-app ads.", + compatiblePackages = [CompatiblePackage("at.willhaben")] +) +@Suppress("unused") +object HideAdsPatch : BytecodePatch( + fingerprints = setOf( + AdResolverFingerprint, + WHAdViewInjectorFingerprint + ) +) { + override fun execute(context: BytecodeContext) { + arrayOf(AdResolverFingerprint, WHAdViewInjectorFingerprint).forEach { + it.returnEarly() + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/AdResolverFingerprint.kt b/src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/AdResolverFingerprint.kt new file mode 100644 index 0000000000..99b05db514 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/AdResolverFingerprint.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.willhaben.ads.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object AdResolverFingerprint : MethodFingerprint( + "L", + parameters = listOf("L", "L"), + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + strings = listOf( + "Google Ad is invalid ", + "Google Native Ad is invalid ", + "Criteo Ad is invalid ", + "Amazon Ad is invalid " + ) +) diff --git a/src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/WHAdViewInjectorFingerprint.kt b/src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/WHAdViewInjectorFingerprint.kt new file mode 100644 index 0000000000..b3cb3e2345 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/WHAdViewInjectorFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.willhaben.ads.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object WHAdViewInjectorFingerprint : MethodFingerprint( + "V", + parameters = listOf("L", "L", "L", "Z"), + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + strings = listOf("successfulAdView"), + customFingerprint = { _, classDef -> + classDef.type == "Lat/willhaben/advertising/WHAdView;" + } +)