mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
better autorepeat patch
This commit is contained in:
@ -14,17 +14,21 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||||
import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch
|
import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint.*
|
import app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint.*
|
||||||
|
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||||
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import org.jf.dexlib2.iface.reference.FieldReference
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
import org.jf.dexlib2.iface.reference.MethodReference
|
||||||
import org.jf.dexlib2.immutable.ImmutableMethod
|
import org.jf.dexlib2.immutable.ImmutableMethod
|
||||||
@ -57,10 +61,25 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
|||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
RepeatListenerFingerprint.result?.let {
|
RepeatListenerFingerprint.result?.let {
|
||||||
val removeIndex = it.scanResult.patternScanResult!!.startIndex
|
val targetIndex = it.scanResult.patternScanResult!!.startIndex - 1
|
||||||
|
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
with (it.mutableMethod) {
|
with (it.mutableMethod) {
|
||||||
// removeInstruction(removeIndex)
|
val targetReference = (instruction(targetIndex) as BuilderInstruction35c).reference.toString()
|
||||||
removeInstruction(removeIndex - 1)
|
|
||||||
|
val firstRegister = (instruction(targetIndex) as BuilderInstruction35c).registerC
|
||||||
|
val secondRegister = (instruction(targetIndex) as BuilderInstruction35c).registerD
|
||||||
|
|
||||||
|
val dummyRegister = (instruction(endIndex) as Instruction31i).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
targetIndex + 1, """
|
||||||
|
invoke-static {}, $UTILS_PATH/EnableAutoRepeatPatch;->shouldAutoRepeat()Z
|
||||||
|
move-result v$dummyRegister
|
||||||
|
if-nez v$dummyRegister, :bypass
|
||||||
|
invoke-virtual {v$firstRegister, v$secondRegister}, $targetReference
|
||||||
|
""", listOf(ExternalLabel("bypass", instruction(targetIndex + 1)))
|
||||||
|
)
|
||||||
|
removeInstruction(targetIndex)
|
||||||
}
|
}
|
||||||
} ?: return RepeatListenerFingerprint.toErrorResult()
|
} ?: return RepeatListenerFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user