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 00000000..97d975c3 --- /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 00000000..c8728227 --- /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