From 8fbe7e3d38c43adfa0755bcbe87f8c6b7696da3a Mon Sep 17 00:00:00 2001 From: Twin Date: Thu, 27 Jun 2024 16:27:59 -0400 Subject: [PATCH] feat(RAR): Add `Hide purchase reminder` patch (#3321) Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 10 ++++++++ .../HidePurchaseReminderPatch.kt | 24 +++++++++++++++++++ .../fingerprints/ShowReminderFingerprint.kt | 13 ++++++++++ 3 files changed, 47 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/fingerprints/ShowReminderFingerprint.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 320f2475..805eda8b 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -535,6 +535,16 @@ public final class app/revanced/patches/pixiv/ads/HideAdsPatch : app/revanced/pa public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch; + 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/rar/misc/annoyances/purchasereminder/fingerprints/ShowReminderFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint { + public static final field INSTANCE Lapp/revanced/patches/rar/misc/annoyances/purchasereminder/fingerprints/ShowReminderFingerprint; +} + public final class app/revanced/patches/reddit/ad/banner/HideBannerPatch : app/revanced/patcher/patch/ResourcePatch { public static final field INSTANCE Lapp/revanced/patches/reddit/ad/banner/HideBannerPatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V diff --git a/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt b/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt new file mode 100644 index 00000000..491a53fe --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt @@ -0,0 +1,24 @@ +package app.revanced.patches.rar.misc.annoyances.purchasereminder + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.rar.misc.annoyances.purchasereminder.fingerprints.ShowReminderFingerprint +import app.revanced.util.exception + +@Patch( + name = "Hide purchase reminder", + description = "Hides the popup that reminds you to purchase the app.", + compatiblePackages = [CompatiblePackage("com.rarlab.rar")], +) +@Suppress("unused") +object HidePurchaseReminderPatch : BytecodePatch( + setOf(ShowReminderFingerprint), +) { + override fun execute(context: BytecodeContext) { + ShowReminderFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") + ?: throw ShowReminderFingerprint.exception + } +} diff --git a/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/fingerprints/ShowReminderFingerprint.kt b/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/fingerprints/ShowReminderFingerprint.kt new file mode 100644 index 00000000..c64b0022 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/fingerprints/ShowReminderFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.rar.misc.annoyances.purchasereminder.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +object ShowReminderFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("AdsNotify;") && methodDef.name == "show" + }, +)