Skip to content

Commit

Permalink
feat(Twitter): Added Hide followed by context patch
Browse files Browse the repository at this point in the history
  • Loading branch information
swakwork committed Sep 26, 2024
1 parent d7572fe commit 261e1d0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package crimera.patches.twitter.timeline.hideSocialProof

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction23x
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint

object HideSocialProofPatchFingerprint : MethodFingerprint(

customFingerprint = {methodDef, classDef ->
classDef.type.endsWith("SocialProofView;") && methodDef.name == "setSocialProofData"
}
)

@Patch(
name = "Hide followed by context",
description = "Hides followed by context under profile",
compatiblePackages = [CompatiblePackage("com.twitter.android")],
dependencies = [SettingsPatch::class],
use = true,
)
@Suppress("unused")
object HideSocialProofPatch:BytecodePatch(
setOf(HideSocialProofPatchFingerprint,SettingsStatusLoadFingerprint)
) {
const val HOOK_DESCRIPTOR =
"invoke-static {}, ${SettingsPatch.PREF_DESCRIPTOR};->hideSocialProof()Z"

override fun execute(context: BytecodeContext) {
val result = HideSocialProofPatchFingerprint.result
?: throw PatchException("HideSocialProofPatchFingerprint not found")

val method = result.mutableMethod
val instructions = method.getInstructions()



method.addInstructionsWithLabels(0,"""
$HOOK_DESCRIPTOR
move-result v0
if-eqz v0, :piko
return-void
""".trimIndent(), ExternalLabel("piko",instructions.first { it.opcode == Opcode.CONST_4})
)

SettingsStatusLoadFingerprint.enableSettings("hideSocialProof")

}
}
4 changes: 3 additions & 1 deletion src/main/resources/twitter/settings/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@
<string name="piko_pref_enable_vid_auto_advance_desc">Enables video auto scroll in immersive view</string>
<string name="piko_pref_hide_hidden_replies">hidden replies</string>
<string name="piko_pref_force_hd">force HD videos</string>
<string name="piko_pref_force_hd_desc">Videos will be played in highest quality always</string>
<string name="piko_pref_force_hd_desc">Videos will be played in the highest quality always</string>
<string name="piko_pref_hide_nudge_button">Hide nudge button</string>
<string name="piko_pref_hide_nudge_button_desc">Hides follow/subscribe/follow back buttons on posts</string>
<string name="piko_pref_hide_social_proof">Hide followed by context</string>
<string name="piko_pref_hide_social_proof_desc">Hides followed by context under profile</string>

<string name="piko_title_customisation">Customization</string>
<string name="piko_pref_customisation_profiletabs">Profile tabs to hide</string>
Expand Down

0 comments on commit 261e1d0

Please sign in to comment.