From ad8d3bb1c86f1324234e890f1171ec4a18e56dd9 Mon Sep 17 00:00:00 2001 From: xob0t <32616886+xob0t@users.noreply.github.com> Date: Thu, 11 Jul 2024 01:21:40 +0300 Subject: [PATCH] feat(Bandcamp): Add `Remove play limits` patch (#3366) Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 6 +++++ .../limitations/RemovePlayLimitsPatch.kt | 23 +++++++++++++++++++ .../fingerprints/HandlePlaybackLimitsPatch.kt | 7 ++++++ 3 files changed, 36 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/bandcamp/limitations/fingerprints/HandlePlaybackLimitsPatch.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index f0e32381..4530ff7c 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -181,6 +181,12 @@ public final class app/revanced/patches/backdrops/misc/pro/ProUnlockPatch : app/ public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch; + 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/candylinkvpn/UnlockProPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/candylinkvpn/UnlockProPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt b/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt new file mode 100644 index 00000000..b7620bfa --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.bandcamp.limitations + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.bandcamp.limitations.fingerprints.HandlePlaybackLimitsPatch +import app.revanced.util.exception + +@Patch( + name = "Remove play limits", + description = "Disables purchase nagging and playback limits of not purchased tracks.", + compatiblePackages = [CompatiblePackage("com.bandcamp.android")], +) +@Suppress("unused") +object RemovePlayLimitsPatch : BytecodePatch( + setOf(HandlePlaybackLimitsPatch), +) { + override fun execute(context: BytecodeContext) = + HandlePlaybackLimitsPatch.result?.mutableMethod?.addInstructions(0, "return-void") + ?: throw HandlePlaybackLimitsPatch.exception +} diff --git a/src/main/kotlin/app/revanced/patches/bandcamp/limitations/fingerprints/HandlePlaybackLimitsPatch.kt b/src/main/kotlin/app/revanced/patches/bandcamp/limitations/fingerprints/HandlePlaybackLimitsPatch.kt new file mode 100644 index 00000000..5465800e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/bandcamp/limitations/fingerprints/HandlePlaybackLimitsPatch.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.bandcamp.limitations.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object HandlePlaybackLimitsPatch : MethodFingerprint( + strings = listOf("play limits processing track", "found play_count"), +)