mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-26 12:11:02 +00:00
refactor(myfitnesspal): HideAdsPatch
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
package app.revanced.patches.myfitnesspal.ads
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
|
||||
import app.revanced.patcher.accessFlags
|
||||
import app.revanced.patcher.definingClass
|
||||
import app.revanced.patcher.name
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.returnType
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal val isPremiumUseCaseImplFingerprint = fingerprint {
|
||||
internal val BytecodePatchContext.isPremiumUseCaseImplMethod by gettingFirstMutableMethodDeclaratively {
|
||||
accessFlags(AccessFlags.PUBLIC)
|
||||
custom { method, classDef ->
|
||||
classDef.endsWith("IsPremiumUseCaseImpl;") && method.name == "doWork"
|
||||
}
|
||||
definingClass("IsPremiumUseCaseImpl;")
|
||||
name("doWork")
|
||||
}
|
||||
|
||||
internal val mainActivityNavigateToNativePremiumUpsellFingerprint = fingerprint {
|
||||
internal val BytecodePatchContext.mainActivityNavigateToNativePremiumUpsellMethod by gettingFirstMutableMethodDeclaratively {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
custom { method, classDef ->
|
||||
classDef.endsWith("MainActivity;") && method.name == "navigateToNativePremiumUpsell"
|
||||
}
|
||||
returnType("V")
|
||||
definingClass("MainActivity;")
|
||||
name("navigateToNativePremiumUpsell")
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package app.revanced.patches.myfitnesspal.ads
|
||||
|
||||
import app.revanced.patcher.extensions.replaceInstructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.creatingBytecodePatch
|
||||
|
||||
@Suppress("unused")
|
||||
val hideAdsPatch = bytecodePatch(
|
||||
name = "Hide ads",
|
||||
description = "Hides most of the ads across the app.",
|
||||
@Suppress("unused", "ObjectPropertyName")
|
||||
val `Hide ads` by creatingBytecodePatch(
|
||||
description = "Hides most of the ads across the app."
|
||||
) {
|
||||
compatibleWith("com.myfitnesspal.android"("24.14.2"))
|
||||
|
||||
apply {
|
||||
// Overwrite the premium status specifically for ads.
|
||||
isPremiumUseCaseImplFingerprint.method.replaceInstructions(
|
||||
isPremiumUseCaseImplMethod.replaceInstructions(
|
||||
0,
|
||||
"""
|
||||
sget-object v0, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean;
|
||||
@@ -22,7 +21,7 @@ val hideAdsPatch = bytecodePatch(
|
||||
|
||||
// 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.method.replaceInstructions(
|
||||
mainActivityNavigateToNativePremiumUpsellMethod.replaceInstructions(
|
||||
0,
|
||||
"return-void",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user