From a4d6b4e5ce6065d932f3895b4996e7dc1e5f7c67 Mon Sep 17 00:00:00 2001 From: Temm Date: Thu, 14 Sep 2023 00:12:36 +0200 Subject: [PATCH] feat(Tumblr): Add `Disable gift message popup` patch --- .../ShowGiftMessagePopupFingerprint.kt | 9 +++++++ .../patch/DisableGiftMessagePopupPatch.kt | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/patch/DisableGiftMessagePopupPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt new file mode 100644 index 0000000000..22ee4015c0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.tumblr.annoyances.popups.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +// This method is responsible for loading and displaying the visual Layout of the Gift Message Popup. +object ShowGiftMessagePopupFingerprint : MethodFingerprint( + strings = listOf("activity", "anchorView"), + customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("GiftMessagePopup;") } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/patch/DisableGiftMessagePopupPatch.kt b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/patch/DisableGiftMessagePopupPatch.kt new file mode 100644 index 0000000000..9a0b0e8c3f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/patch/DisableGiftMessagePopupPatch.kt @@ -0,0 +1,24 @@ +package app.revanced.patches.tumblr.annoyances.popups.patch + +import app.revanced.extensions.exception +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Package +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.tumblr.annoyances.popups.fingerprints.ShowGiftMessagePopupFingerprint + +@Patch +@Name("Disable gift message popup") +@Description("Disables the popup suggesting to buy TumblrMart items for other people.") +@Compatibility([Package("com.tumblr")]) +class DisableGiftMessagePopupPatch : BytecodePatch( + listOf(ShowGiftMessagePopupFingerprint) +) { + override fun execute(context: BytecodeContext) = + ShowGiftMessagePopupFingerprint.result?.mutableMethod?.addInstructions(0, "return-void") + ?: throw ShowGiftMessagePopupFingerprint.exception +} \ No newline at end of file