Skip to content

Commit

Permalink
feat: Add Show poll results patch
Browse files Browse the repository at this point in the history
  • Loading branch information
crimera committed Apr 7, 2024
1 parent 96c9b4d commit 7b48f1b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package crimera.patches.twitter.timeline.showpollresults

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
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 com.android.tools.smali.dexlib2.Opcode
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.timeline.showpollresults.fingerprints.JsonCardInstanceDataFingerprint

@Patch(
name = "Show poll results",
compatiblePackages = [CompatiblePackage("com.twitter.android")]
)
object ShowPollResultsPatch: BytecodePatch(
setOf(JsonCardInstanceDataFingerprint)
) {
override fun execute(context: BytecodeContext) {
val result = JsonCardInstanceDataFingerprint.result
?: throw PatchException("Could not find JsonCardInstanceData Fingerprint")

val method = result.mutableMethod

val loc = method.getInstructions().first { it.opcode == Opcode.MOVE_RESULT_OBJECT }.location.index

val pollDescriptor =
"invoke-static {p2}, ${SettingsPatch.PREF_DESCRIPTOR};->polls(Ljava/util/Map;)Ljava/util/Map;"

method.addInstructions(
loc+1,
"""
$pollDescriptor
move-result-object p2
""".trimIndent()
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package crimera.patches.twitter.timeline.showpollresults.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object JsonCardInstanceDataFingerprint: MethodFingerprint(
strings = listOf(
"binding_values"
)
)

0 comments on commit 7b48f1b

Please sign in to comment.