forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Willhaben): Add
Hide ads
patch (ReVanced#3740)
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/app/revanced/patches/willhaben/ads/fingerprints/AdResolverFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 " | ||
) | ||
) |
15 changes: 15 additions & 0 deletions
15
...ain/kotlin/app/revanced/patches/willhaben/ads/fingerprints/WHAdViewInjectorFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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;" | ||
} | ||
) |