mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-25 03:12:10 +02:00
feat(youtube): improve patching speed
This commit is contained in:
parent
c97f1a7314
commit
92b6e02039
@ -0,0 +1,53 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.videoid.withoutshorts.fingerprint
|
||||||
|
|
||||||
|
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 VideoIdWithoutShortsFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.DECLARED_SYNCHRONIZED,
|
||||||
|
parameters = listOf("L"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.MONITOR_ENTER,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.NEW_ARRAY,
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.APUT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.IF_EQZ,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.IPUT_OBJECT,
|
||||||
|
Opcode.MONITOR_EXIT,
|
||||||
|
Opcode.RETURN_VOID,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.NEW_ARRAY,
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
Opcode.APUT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.IF_EQZ,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.IF_EQZ,
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.IPUT_OBJECT,
|
||||||
|
Opcode.MONITOR_EXIT,
|
||||||
|
Opcode.RETURN_VOID,
|
||||||
|
Opcode.MONITOR_EXIT,
|
||||||
|
Opcode.RETURN_VOID,
|
||||||
|
Opcode.MOVE_EXCEPTION,
|
||||||
|
Opcode.MONITOR_EXIT,
|
||||||
|
Opcode.THROW
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef, classDef ->
|
||||||
|
methodDef.name == "l" && classDef.methods.count() == 17
|
||||||
|
}
|
||||||
|
)
|
@ -1,23 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.utils.videoid.withoutshorts.fingerprint
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import app.revanced.util.bytecode.isWideLiteralExists
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
object VideoIdWithoutShortsParentFingerprint : MethodFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
parameters = listOf("L"),
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.CHECK_CAST,
|
|
||||||
Opcode.CHECK_CAST,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.RETURN_VOID
|
|
||||||
),
|
|
||||||
customFingerprint = { methodDef, _ ->
|
|
||||||
methodDef.isWideLiteralExists(78882851)
|
|
||||||
}
|
|
||||||
)
|
|
@ -11,7 +11,7 @@ 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.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.youtube.utils.videoid.withoutshorts.fingerprint.VideoIdWithoutShortsParentFingerprint
|
import app.revanced.patches.youtube.utils.videoid.withoutshorts.fingerprint.VideoIdWithoutShortsFingerprint
|
||||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
@ -19,15 +19,12 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Name("video-id-without-shorts-hook")
|
@Name("video-id-without-shorts-hook")
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class VideoIdWithoutShortsPatch : BytecodePatch(
|
class VideoIdWithoutShortsPatch : BytecodePatch(
|
||||||
listOf(VideoIdWithoutShortsParentFingerprint)
|
listOf(VideoIdWithoutShortsFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
VideoIdWithoutShortsParentFingerprint.result?.let {
|
VideoIdWithoutShortsFingerprint.result?.let {
|
||||||
insertMethod = context
|
insertMethod = it.mutableMethod
|
||||||
.toMethodWalker(it.method)
|
|
||||||
.nextMethod(it.scanResult.patternScanResult!!.startIndex + 3, true)
|
|
||||||
.getMethod() as MutableMethod
|
|
||||||
|
|
||||||
insertIndex = insertMethod.implementation!!.instructions.indexOfFirst { instruction ->
|
insertIndex = insertMethod.implementation!!.instructions.indexOfFirst { instruction ->
|
||||||
instruction.opcode == Opcode.INVOKE_INTERFACE
|
instruction.opcode == Opcode.INVOKE_INTERFACE
|
||||||
@ -35,7 +32,7 @@ class VideoIdWithoutShortsPatch : BytecodePatch(
|
|||||||
|
|
||||||
insertRegister =
|
insertRegister =
|
||||||
insertMethod.getInstruction<OneRegisterInstruction>(insertIndex + 1).registerA
|
insertMethod.getInstruction<OneRegisterInstruction>(insertIndex + 1).registerA
|
||||||
} ?: return VideoIdWithoutShortsParentFingerprint.toErrorResult()
|
} ?: return VideoIdWithoutShortsFingerprint.toErrorResult()
|
||||||
|
|
||||||
injectCall("$VIDEO_PATH/VideoInformation;->setVideoId(Ljava/lang/String;)V")
|
injectCall("$VIDEO_PATH/VideoInformation;->setVideoId(Ljava/lang/String;)V")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user