From 29f19b9378c7e167137f38fa4517ae19382ca4f6 Mon Sep 17 00:00:00 2001 From: Temm Date: Thu, 14 Sep 2023 00:11:36 +0200 Subject: [PATCH] feat(Tumblr): Add `Disable blog notification reminder` patch --- .../IsBlogNotifyEnabledFingerprint.kt | 9 ++++++ .../DisableBlogNotificationReminderPatch.kt | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/fingerprints/IsBlogNotifyEnabledFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/patch/DisableBlogNotificationReminderPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/fingerprints/IsBlogNotifyEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/fingerprints/IsBlogNotifyEnabledFingerprint.kt new file mode 100644 index 000000000..97d975c3d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/fingerprints/IsBlogNotifyEnabledFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.tumblr.annoyances.notifications.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +// The BlogNotifyCtaDialog asks you if you want to enable notifications for a blog. +// It shows whenever you visit a certain blog for the second time and disables itself +// if it was shown a total of 3 times (stored in app storage). +// This targets the BlogNotifyCtaDialog.isEnabled() method to let it always return false. +object IsBlogNotifyEnabledFingerprint : MethodFingerprint(strings = listOf("isEnabled --> ", "blog_notify_enabled")) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/patch/DisableBlogNotificationReminderPatch.kt b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/patch/DisableBlogNotificationReminderPatch.kt new file mode 100644 index 000000000..c8728227a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/patch/DisableBlogNotificationReminderPatch.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.tumblr.annoyances.notifications.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.notifications.fingerprints.IsBlogNotifyEnabledFingerprint + +@Patch +@Name("Disable blog notification reminder") +@Description("Disables the reminder to enable notifications for blogs you visit.") +@Compatibility([Package("com.tumblr")]) +class DisableBlogNotificationReminderPatch : BytecodePatch( + listOf(IsBlogNotifyEnabledFingerprint) +) { + override fun execute(context: BytecodeContext) = + IsBlogNotifyEnabledFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + # Return false for BlogNotifyCtaDialog.isEnabled() method. + const/4 v0, 0x0 + return v0 + """ + ) ?: throw IsBlogNotifyEnabledFingerprint.exception +} \ No newline at end of file