forked from crimera/piko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Twitter): Added
Control video auto scroll
patch
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...kotlin/crimera/patches/twitter/timeline/enableVidAutoAdvance/EnableVidAutoAdvancePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package crimera.patches.twitter.timeline.enableVidAutoAdvance | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
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 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") | ||
) | ||
|
||
|
||
@Patch( | ||
name = "Control video auto scroll", | ||
description = "Control video auto scroll in immersive view", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
dependencies = [SettingsPatch::class], | ||
use = false | ||
) | ||
@Suppress("unused") | ||
class EnableVidAutoAdvancePatch : BytecodePatch( | ||
setOf(EnableVidAutoAdvancePatchFingerprint,SettingsStatusLoadFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val result = EnableVidAutoAdvancePatchFingerprint.result | ||
?: throw PatchException("EnableVidAutoAdvancePatchFingerprint not found") | ||
|
||
var strLoc: Int = 0 | ||
result.scanResult.stringsScanResult!!.matches.forEach{ match -> | ||
val str = match.string | ||
if(str.contains("immersive_video_auto_advance_duration_threshold")){ | ||
strLoc = match.index | ||
return@forEach | ||
} | ||
} | ||
if(strLoc==0){ | ||
throw PatchException("hook not found") | ||
} | ||
|
||
val method = result.mutableMethod | ||
val instructions = method.getInstructions() | ||
val loc = strLoc+2 | ||
|
||
val reg = method.getInstruction<OneRegisterInstruction>(loc).registerA | ||
method.addInstruction(loc,""" | ||
invoke-static {}, ${SettingsPatch.PREF_DESCRIPTOR};->enableVidAutoAdvance()I | ||
""".trimIndent()) | ||
|
||
SettingsStatusLoadFingerprint.enableSettings("enableVidAutoAdvance") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters