diff --git a/api/revanced-patches.api b/api/revanced-patches.api index e66cfeba2..262eb3e94 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -1065,6 +1065,12 @@ public final class app/revanced/patches/twitch/misc/settings/SettingsResourcePat public static final field INSTANCE Lapp/revanced/patches/twitch/misc/settings/SettingsResourcePatch; } +public final class app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/twitter/layout/viewcount/HideViewCountPatch; + 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/twitter/misc/dynamiccolor/DynamicColorPatch : app/revanced/patcher/patch/ResourcePatch { public static final field INSTANCE Lapp/revanced/patches/twitter/misc/dynamiccolor/DynamicColorPatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V diff --git a/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt new file mode 100644 index 000000000..9951e50b5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.twitter.layout.viewcount + + +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.twitter.layout.viewcount.fingerprints.ViewCountsEnabledFingerprint +import app.revanced.util.exception + +@Patch( + name = "Hide view count", + description = "Hides the view count of Posts.", + compatiblePackages = [CompatiblePackage("com.twitter.android")], + use = false +) +@Suppress("unused") +object HideViewCountPatch : BytecodePatch( + setOf(ViewCountsEnabledFingerprint) +) { + override fun execute(context: BytecodeContext) = + ViewCountsEnabledFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + const/4 v0, 0x0 + return v0 + """ + ) ?: throw ViewCountsEnabledFingerprint.exception +} diff --git a/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/fingerprints/ViewCountsEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/fingerprints/ViewCountsEnabledFingerprint.kt new file mode 100644 index 000000000..3b3e7affd --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/fingerprints/ViewCountsEnabledFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.twitter.layout.viewcount.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object ViewCountsEnabledFingerprint : MethodFingerprint( + returnType = "Z", + strings = listOf("view_counts_public_visibility_enabled") +)