Skip to content

Commit

Permalink
fix(Twitter): fix Control video auto scroll in 10.57
Browse files Browse the repository at this point in the history
  • Loading branch information
swakwork committed Sep 5, 2024
1 parent f89c152 commit b7ae78c
Showing 1 changed file with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,55 @@ 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 com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint

object EnableVidAutoAdvancePatchFingerprint: MethodFingerprint(
strings = listOf("immersive_video_auto_advance_duration_threshold")
object EnableVidAutoAdvancePatchFingerprint : MethodFingerprint(
strings = listOf("immersive_video_auto_advance_duration_threshold"),
)


@Patch(
name = "Control video auto scroll",
description = "Control video auto scroll in immersive view",
compatiblePackages = [CompatiblePackage("com.twitter.android")],
dependencies = [SettingsPatch::class],
use = true
use = true,
)
@Suppress("unused")
class EnableVidAutoAdvancePatch : BytecodePatch(
setOf(EnableVidAutoAdvancePatchFingerprint,SettingsStatusLoadFingerprint)
) {
class EnableVidAutoAdvancePatch :
BytecodePatch(
setOf(EnableVidAutoAdvancePatchFingerprint, SettingsStatusLoadFingerprint),
) {
override fun execute(context: BytecodeContext) {
val result = EnableVidAutoAdvancePatchFingerprint.result
?: throw PatchException("EnableVidAutoAdvancePatchFingerprint not found")
val result =
EnableVidAutoAdvancePatchFingerprint.result
?: throw PatchException("EnableVidAutoAdvancePatchFingerprint not found")

var strLoc: Int = 0
result.scanResult.stringsScanResult!!.matches.forEach{ match ->
result.scanResult.stringsScanResult!!.matches.forEach { match ->
val str = match.string
if(str.contains("immersive_video_auto_advance_duration_threshold")){
if (str.contains("immersive_video_auto_advance_duration_threshold")) {
strLoc = match.index
return@forEach
}
}
if(strLoc==0){
if (strLoc == 0) {
throw PatchException("hook not found")
}

val method = result.mutableMethod
val instructions = method.getInstructions()
val loc = strLoc+2

val loc = instructions.first { it.opcode == Opcode.MOVE_RESULT && it.location.index > strLoc }.location.index
val reg = method.getInstruction<OneRegisterInstruction>(loc).registerA
method.addInstruction(loc,"""
method.addInstruction(
loc,
"""
invoke-static {}, ${SettingsPatch.PREF_DESCRIPTOR};->enableVidAutoAdvance()I
""".trimIndent())
""".trimIndent(),
)

SettingsStatusLoadFingerprint.enableSettings("enableVidAutoAdvance")
}
}
}

0 comments on commit b7ae78c

Please sign in to comment.