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(MyFitnessPal): Add
Hide ads
patch (ReVanced#2594)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
4 changed files
with
76 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
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/app/revanced/patches/myfitnesspal/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,38 @@ | ||
package app.revanced.patches.myfitnesspal.ads | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.myfitnesspal.ads.fingerprints.IsPremiumUseCaseImplFingerprint | ||
import app.revanced.patches.myfitnesspal.ads.fingerprints.MainActivityNavigateToNativePremiumUpsellFingerprint | ||
import app.revanced.util.exception | ||
|
||
@Patch( | ||
name = "Hide ads", | ||
description = "Hides most of the ads across the app.", | ||
compatiblePackages = [CompatiblePackage("com.myfitnesspal.android")] | ||
) | ||
@Suppress("unused") | ||
object HideAdsPatch : BytecodePatch( | ||
setOf(IsPremiumUseCaseImplFingerprint, MainActivityNavigateToNativePremiumUpsellFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
// Overwrite the premium status specifically for ads. | ||
IsPremiumUseCaseImplFingerprint.result?.mutableMethod?.replaceInstructions( | ||
0, | ||
""" | ||
sget-object v0, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean; | ||
return-object v0 | ||
""" | ||
) ?: throw IsPremiumUseCaseImplFingerprint.exception | ||
|
||
// Prevent the premium upsell dialog from showing when the main activity is launched. | ||
// In other places that are premium-only the dialog will still show. | ||
MainActivityNavigateToNativePremiumUpsellFingerprint.result?.mutableMethod?.replaceInstructions( | ||
0, | ||
"return-void" | ||
) ?: throw MainActivityNavigateToNativePremiumUpsellFingerprint.exception | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...lin/app/revanced/patches/myfitnesspal/ads/fingerprints/IsPremiumUseCaseImplFingerprint.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,11 @@ | ||
package app.revanced.patches.myfitnesspal.ads.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
|
||
object IsPremiumUseCaseImplFingerprint : MethodFingerprint( | ||
accessFlags = AccessFlags.PUBLIC.value, | ||
customFingerprint = { methodDef, classDef -> | ||
classDef.type.endsWith("IsPremiumUseCaseImpl;") && methodDef.name == "doWork" | ||
} | ||
) |
13 changes: 13 additions & 0 deletions
13
...hes/myfitnesspal/ads/fingerprints/MainActivityNavigateToNativePremiumUpsellFingerprint.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,13 @@ | ||
package app.revanced.patches.myfitnesspal.ads.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
|
||
object MainActivityNavigateToNativePremiumUpsellFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, | ||
customFingerprint = { methodDef, classDef -> | ||
classDef.type.endsWith("MainActivity;") && methodDef.name == "navigateToNativePremiumUpsell" | ||
} | ||
) |