Skip to content

Commit

Permalink
feat(Twitter): Add Settings for Hide Recommended Users patch
Browse files Browse the repository at this point in the history
  • Loading branch information
crimera committed Mar 18, 2024
1 parent ae69e22 commit f43f027
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package crimera.patches.twitter.recommendedusers

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
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.patch.options.PatchOption.PatchExtensions.stringArrayPatchOption
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import crimera.patches.twitter.recommendedusers.fingerprints.HideRecommendedUsersFingerprint


Expand All @@ -34,8 +35,17 @@ object HideRecommendedUsers: BytecodePatch(
val check = instructions.last { it.opcode == Opcode.IGET_OBJECT }.location.index
val reg = method.getInstruction<OneRegisterInstruction>(check).registerA

method.addInstruction(check+1, """
const v$reg, 0x0
val HIDE_RECOMMENDED_USERS_DESCRIPTOR =
"invoke-static {v$reg}, ${SettingsPatch.PREF_DESCRIPTOR};->hideRecommendedUsers(Ljava/util/ArrayList;)Ljava/util/ArrayList;"

method.addInstructions(check+1, """
$HIDE_RECOMMENDED_USERS_DESCRIPTOR
move-result-object v$reg
""".trimIndent())

SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"${SettingsPatch.SSTS_DESCRIPTOR}->hideRecommendedUsers()V"
)
}
}

0 comments on commit f43f027

Please sign in to comment.