mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-12 04:13:57 +01:00
feat(Duolingo): Add Skip energy recharge ads patch (#6167)
This commit is contained in:
@@ -184,6 +184,10 @@ public final class app/revanced/patches/duolingo/debug/EnableDebugMenuPatchKt {
|
|||||||
public static final fun getEnableDebugMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getEnableDebugMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class app/revanced/patches/duolingo/energy/SkipEnergyRechargeAdsPatchKt {
|
||||||
|
public static final fun getSkipEnergyRechargeAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
|
}
|
||||||
|
|
||||||
public final class app/revanced/patches/facebook/ads/mainfeed/HideSponsoredStoriesPatchKt {
|
public final class app/revanced/patches/facebook/ads/mainfeed/HideSponsoredStoriesPatchKt {
|
||||||
public static final fun getHideSponsoredStoriesPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
public static final fun getHideSponsoredStoriesPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package app.revanced.patches.duolingo.energy
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches the class found in [energyConfigToStringFingerprint].
|
||||||
|
*/
|
||||||
|
internal val initializeEnergyConfigFingerprint = fingerprint {
|
||||||
|
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||||
|
opcodes(Opcode.RETURN_VOID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Class name currently is not obfuscated but it may be in the future.
|
||||||
|
internal val energyConfigToStringFingerprint = fingerprint {
|
||||||
|
parameters()
|
||||||
|
returns("Ljava/lang/String;")
|
||||||
|
strings("EnergyConfig(", "maxEnergy=") // Partial string matches.
|
||||||
|
custom { method, _ -> method.name == "toString" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package app.revanced.patches.duolingo.energy
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
|
import app.revanced.util.findFieldFromToString
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
val skipEnergyRechargeAdsPatch = bytecodePatch(
|
||||||
|
name = "Skip energy recharge ads",
|
||||||
|
description = "Skips watching ads to recharge energy."
|
||||||
|
) {
|
||||||
|
compatibleWith("com.duolingo")
|
||||||
|
|
||||||
|
execute {
|
||||||
|
initializeEnergyConfigFingerprint
|
||||||
|
.match(energyConfigToStringFingerprint.classDef)
|
||||||
|
.method.apply {
|
||||||
|
val energyField = energyConfigToStringFingerprint.method
|
||||||
|
.findFieldFromToString("energy=")
|
||||||
|
val insertIndex = initializeEnergyConfigFingerprint.patternMatch!!.startIndex
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
const/16 v0, 99
|
||||||
|
iput v0, p0, $energyField
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user