mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 09:07:46 +01:00
feat: tiktok-speed
patch (#668)
This commit is contained in:
parent
1a9d942a8c
commit
9746b50055
3 changed files with 86 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
|||
package app.revanced.patches.tiktok.interaction.speed.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[
|
||||
Package("com.ss.android.ugc.trill"),
|
||||
Package("com.zhiliaoapp.musically")
|
||||
]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class SpeedCompatibility
|
|
@ -0,0 +1,24 @@
|
|||
package app.revanced.patches.tiktok.interaction.speed.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.tiktok.interaction.speed.annotations.SpeedCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
@Name("speed-control-parent-fingerprint")
|
||||
@MatchingMethod("LX/4cP;", "LJIILL")
|
||||
@SpeedCompatibility
|
||||
@Version("0.0.1")
|
||||
object SpeedControlParentFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||
parameters = listOf(
|
||||
"L"
|
||||
),
|
||||
strings = listOf(
|
||||
"playback_speed"
|
||||
)
|
||||
)
|
|
@ -0,0 +1,48 @@
|
|||
package app.revanced.patches.tiktok.interaction.speed.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.impl.BytecodeData
|
||||
import app.revanced.patcher.data.impl.toMethodWalker
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.tiktok.interaction.speed.annotations.SpeedCompatibility
|
||||
import app.revanced.patches.tiktok.interaction.speed.fingerprints.SpeedControlParentFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Patch
|
||||
@Name("tiktok-speed")
|
||||
@Description("Enables the playback speed option for all videos.")
|
||||
@SpeedCompatibility
|
||||
@Version("0.0.1")
|
||||
class SpeedPatch : BytecodePatch(
|
||||
listOf(
|
||||
SpeedControlParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
val parentMethod = SpeedControlParentFingerprint.result!!.mutableMethod
|
||||
val parentMethodInstructions = parentMethod.implementation!!.instructions
|
||||
for ((index, instruction) in parentMethodInstructions.withIndex()) {
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue
|
||||
val isSpeedEnableMethod = data
|
||||
.toMethodWalker(parentMethod)
|
||||
.nextMethod(index, true)
|
||||
.getMethod() as MutableMethod
|
||||
isSpeedEnableMethod.addInstructions(
|
||||
0,
|
||||
"""
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
break
|
||||
}
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue