mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
refactor(enable-auto-repeat): changed so that patches are made in the correct path
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
package app.revanced.patches.youtube.button.autorepeat.fingerprints
|
package app.revanced.patches.shared.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
object AutoRepeatFingerprint : MethodFingerprint(
|
object VideoEndFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf(),
|
parameters = listOf(),
|
@ -1,10 +1,10 @@
|
|||||||
package app.revanced.patches.youtube.button.autorepeat.fingerprints
|
package app.revanced.patches.shared.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
object AutoRepeatParentFingerprint : MethodFingerprint(
|
object VideoEndParentFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
strings = listOf(
|
strings = listOf(
|
@ -0,0 +1,21 @@
|
|||||||
|
package app.revanced.patches.youtube.button.autorepeat.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object RepeatListenerFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Z",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL_RANGE,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.CHECK_CAST,
|
||||||
|
Opcode.CONST_WIDE_32
|
||||||
|
),
|
||||||
|
strings = listOf(
|
||||||
|
"ppoobsa"
|
||||||
|
)
|
||||||
|
)
|
@ -4,43 +4,70 @@ import app.revanced.extensions.toErrorResult
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.*
|
||||||
import app.revanced.patcher.extensions.instruction
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
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.shared.fingerprints.VideoEndFingerprint
|
||||||
|
import app.revanced.patches.shared.fingerprints.VideoEndParentFingerprint
|
||||||
import app.revanced.patches.youtube.button.autorepeat.fingerprints.*
|
import app.revanced.patches.youtube.button.autorepeat.fingerprints.*
|
||||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
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.builder.instruction.BuilderInstruction35c
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
||||||
|
|
||||||
@Name("always-autorepeat")
|
@Name("always-autorepeat")
|
||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class AutoRepeatPatch : BytecodePatch(
|
class AutoRepeatPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
AutoRepeatParentFingerprint,
|
AutoNavInformerFingerprint,
|
||||||
AutoNavInformerFingerprint
|
RepeatListenerFingerprint,
|
||||||
|
VideoEndParentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
AutoRepeatParentFingerprint.result?.classDef?.let { classDef ->
|
VideoEndParentFingerprint.result?.classDef?.let { classDef ->
|
||||||
AutoRepeatFingerprint.also {
|
VideoEndFingerprint.also {
|
||||||
it.resolve(context, classDef)
|
it.resolve(context, classDef)
|
||||||
}.result?.mutableMethod?.let {
|
}.result?.mutableMethod?.let {
|
||||||
it.addInstructions(
|
it.addInstructions(
|
||||||
0, """
|
0, """
|
||||||
invoke-static {}, $VIDEO_PATH/VideoInformation;->videoEnded()Z
|
invoke-static {}, $VIDEO_PATH/VideoInformation;->shouldAutoRepeat()Z
|
||||||
move-result v0
|
move-result v0
|
||||||
if-eqz v0, :noautorepeat
|
if-eqz v0, :notrepeat
|
||||||
return-void
|
return-void
|
||||||
""", listOf(ExternalLabel("noautorepeat", it.instruction(0)))
|
""", listOf(ExternalLabel("notrepeat", it.instruction(0)))
|
||||||
)
|
)
|
||||||
} ?: return AutoRepeatFingerprint.toErrorResult()
|
} ?: return VideoEndFingerprint.toErrorResult()
|
||||||
} ?: return AutoRepeatParentFingerprint.toErrorResult()
|
} ?: return VideoEndParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
RepeatListenerFingerprint.result?.let {
|
||||||
|
val targetIndex = it.scanResult.patternScanResult!!.startIndex - 1
|
||||||
|
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
|
with (it.mutableMethod) {
|
||||||
|
val targetReference = (instruction(targetIndex) as BuilderInstruction35c).reference.toString()
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
AutoNavInformerFingerprint.result?.mutableMethod?.let {
|
AutoNavInformerFingerprint.result?.mutableMethod?.let {
|
||||||
with (it.implementation!!.instructions) {
|
with (it.implementation!!.instructions) {
|
||||||
|
Reference in New Issue
Block a user