mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(video-id): integrate always-repeat
patch and remove unnecessary fingerprints
This commit is contained in:
@ -1,7 +0,0 @@
|
||||
package app.revanced.patches.music.video.information.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object PlayerInitFingerprint : MethodFingerprint(
|
||||
strings = listOf("playVideo called on player response with no videoStreamingData."),
|
||||
)
|
@ -2,6 +2,6 @@ package app.revanced.patches.music.video.information.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object SeekFingerprint : MethodFingerprint(
|
||||
object VideoEndFingerprint : MethodFingerprint(
|
||||
strings = listOf("Attempting to seek during an ad")
|
||||
)
|
@ -14,8 +14,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMu
|
||||
import app.revanced.patches.music.utils.fingerprints.SeekBarConstructorFingerprint
|
||||
import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.video.information.fingerprints.PlayerControllerSetTimeReferenceFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.PlayerInitFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.SeekFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoEndFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoIdParentFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoLengthFingerprint
|
||||
import app.revanced.util.integrations.Constants.MUSIC_VIDEO_PATH
|
||||
@ -33,46 +32,43 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
class VideoInformationPatch : BytecodePatch(
|
||||
listOf(
|
||||
PlayerControllerSetTimeReferenceFingerprint,
|
||||
PlayerInitFingerprint,
|
||||
SeekBarConstructorFingerprint,
|
||||
VideoEndFingerprint,
|
||||
VideoIdParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
PlayerInitFingerprint.result?.let { parentResult ->
|
||||
VideoEndFingerprint.result?.let {
|
||||
playerInitMethod =
|
||||
parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
||||
it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) }
|
||||
|
||||
// hook the player controller for use through integrations
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
||||
|
||||
SeekFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val seekHelperMethod = ImmutableMethod(
|
||||
definingClass,
|
||||
"seekTo",
|
||||
listOf(ImmutableMethodParameter("J", annotations, "time")),
|
||||
"Z",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
annotations, null,
|
||||
MutableMethodImplementation(4)
|
||||
).toMutable()
|
||||
it.mutableMethod.apply {
|
||||
val seekHelperMethod = ImmutableMethod(
|
||||
definingClass,
|
||||
"seekTo",
|
||||
listOf(ImmutableMethodParameter("J", annotations, "time")),
|
||||
"Z",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
annotations, null,
|
||||
MutableMethodImplementation(4)
|
||||
).toMutable()
|
||||
|
||||
val seekSourceEnumType = parameterTypes[1].toString()
|
||||
val seekSourceEnumType = parameterTypes[1].toString()
|
||||
|
||||
seekHelperMethod.addInstructions(
|
||||
0, """
|
||||
seekHelperMethod.addInstructions(
|
||||
0, """
|
||||
sget-object v0, $seekSourceEnumType->a:$seekSourceEnumType
|
||||
invoke-virtual {p0, p1, p2, v0}, ${definingClass}->${name}(J$seekSourceEnumType)Z
|
||||
move-result p1
|
||||
return p1
|
||||
"""
|
||||
)
|
||||
|
||||
parentResult.mutableClass.methods.add(seekHelperMethod)
|
||||
}
|
||||
} ?: throw SeekFingerprint.exception
|
||||
} ?: throw PlayerInitFingerprint.exception
|
||||
)
|
||||
it.mutableClass.methods.add(seekHelperMethod)
|
||||
}
|
||||
} ?: throw VideoEndFingerprint.exception
|
||||
|
||||
|
||||
/**
|
||||
|
@ -3,40 +3,17 @@ package app.revanced.patches.youtube.overlaybutton.alwaysrepeat.patch
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.overlaybutton.alwaysrepeat.fingerprints.AutoNavInformerFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.VideoEndFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.VideoEndParentFingerprint
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
class AlwaysRepeatPatch : BytecodePatch(
|
||||
listOf(
|
||||
AutoNavInformerFingerprint,
|
||||
VideoEndParentFingerprint
|
||||
)
|
||||
listOf(AutoNavInformerFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
VideoEndParentFingerprint.result?.classDef?.let { classDef ->
|
||||
VideoEndFingerprint.also { it.resolve(context, classDef) }.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-static {}, $VIDEO_PATH/VideoInformation;->shouldAlwaysRepeat()Z
|
||||
move-result v0
|
||||
if-eqz v0, :end
|
||||
return-void
|
||||
""", ExternalLabel("end", getInstruction(0))
|
||||
)
|
||||
}
|
||||
} ?: throw VideoEndFingerprint.exception
|
||||
} ?: throw VideoEndParentFingerprint.exception
|
||||
|
||||
AutoNavInformerFingerprint.result?.let {
|
||||
with(
|
||||
|
@ -6,18 +6,16 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints.CoreConatinerBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.fingerprints.VideoEndFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.VideoEndParentFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.CoreContainer
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.videoid.general.patch.VideoIdPatch
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
@ -29,15 +27,13 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
SharedResourceIdPatch::class,
|
||||
VideoIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
class SuggestedVideoOverlayPatch : BytecodePatch(
|
||||
listOf(
|
||||
CoreConatinerBuilderFingerprint,
|
||||
VideoEndParentFingerprint
|
||||
)
|
||||
listOf(CoreConatinerBuilderFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
@ -60,16 +56,12 @@ class SuggestedVideoOverlayPatch : BytecodePatch(
|
||||
}
|
||||
} ?: throw CoreConatinerBuilderFingerprint.exception
|
||||
|
||||
VideoEndParentFingerprint.result?.classDef?.let { classDef ->
|
||||
VideoEndFingerprint.also { it.resolve(context, classDef) }.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
addInstruction(
|
||||
implementation!!.instructions.size - 1,
|
||||
"invoke-static {},$PLAYER->hideSuggestedVideoOverlay()V"
|
||||
)
|
||||
}
|
||||
} ?: throw VideoEndFingerprint.exception
|
||||
} ?: throw VideoEndParentFingerprint.exception
|
||||
VideoIdPatch.videoEndMethod.apply {
|
||||
addInstruction(
|
||||
implementation!!.instructions.size - 1,
|
||||
"invoke-static {},$PLAYER->hideSuggestedVideoOverlay()V"
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
|
@ -1,12 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object VideoEndFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
customFingerprint = { methodDef, _ -> methodDef.implementation!!.instructions.count() == 3 && methodDef.annotations.isEmpty() }
|
||||
)
|
@ -1,14 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object VideoEndParentFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
strings = listOf(
|
||||
"play() called when the player wasn't loaded.",
|
||||
"play() blocked because Background Playability failed"
|
||||
)
|
||||
)
|
@ -1,7 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.videoid.general.fingerprint
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object PlayerInitFingerprint : MethodFingerprint(
|
||||
strings = listOf("playVideo called on player response with no videoStreamingData.")
|
||||
)
|
@ -1,7 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.videoid.general.fingerprint
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object SeekFingerprint : MethodFingerprint(
|
||||
strings = listOf("Attempting to seek during an ad")
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.youtube.utils.videoid.general.fingerprint
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object VideoEndFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.INVOKE_VIRTUAL_RANGE,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.CONST_WIDE_32
|
||||
),
|
||||
strings = listOf("Attempting to seek during an ad")
|
||||
)
|
@ -4,6 +4,7 @@ import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
@ -11,10 +12,10 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.utils.playertype.patch.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.PlayerControllerSetTimeReferenceFingerprint
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.PlayerInitFingerprint
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.SeekFingerprint
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.VideoEndFingerprint
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.VideoIdFingerprint
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.VideoIdParentFingerprint
|
||||
import app.revanced.patches.youtube.utils.videoid.general.fingerprint.VideoLengthFingerprint
|
||||
@ -30,48 +31,59 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
class VideoIdPatch : BytecodePatch(
|
||||
listOf(
|
||||
PlayerControllerSetTimeReferenceFingerprint,
|
||||
PlayerInitFingerprint,
|
||||
SeekFingerprint,
|
||||
VideoEndFingerprint,
|
||||
VideoIdParentFingerprint,
|
||||
VideoLengthFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
PlayerInitFingerprint.result?.let { parentResult ->
|
||||
VideoEndFingerprint.result?.let {
|
||||
playerInitMethod =
|
||||
parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
||||
it.mutableClass.methods.first { method -> MethodUtil.isConstructor(method) }
|
||||
|
||||
// hook the player controller for use through integrations
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
||||
|
||||
SeekFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val seekHelperMethod = ImmutableMethod(
|
||||
definingClass,
|
||||
"seekTo",
|
||||
listOf(ImmutableMethodParameter("J", annotations, "time")),
|
||||
"Z",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
annotations, null,
|
||||
MutableMethodImplementation(4)
|
||||
).toMutable()
|
||||
it.mutableMethod.apply {
|
||||
val seekHelperMethod = ImmutableMethod(
|
||||
definingClass,
|
||||
"seekTo",
|
||||
listOf(ImmutableMethodParameter("J", annotations, "time")),
|
||||
"Z",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
annotations, null,
|
||||
MutableMethodImplementation(4)
|
||||
).toMutable()
|
||||
|
||||
val seekSourceEnumType = parameterTypes[1].toString()
|
||||
val seekSourceEnumType = parameterTypes[1].toString()
|
||||
|
||||
seekHelperMethod.addInstructions(
|
||||
0, """
|
||||
seekHelperMethod.addInstructions(
|
||||
0, """
|
||||
sget-object v0, $seekSourceEnumType->a:$seekSourceEnumType
|
||||
invoke-virtual {p0, p1, p2, v0}, ${definingClass}->${name}(J$seekSourceEnumType)Z
|
||||
move-result p1
|
||||
return p1
|
||||
"""
|
||||
)
|
||||
)
|
||||
it.mutableClass.methods.add(seekHelperMethod)
|
||||
|
||||
parentResult.mutableClass.methods.add(seekHelperMethod)
|
||||
videoEndMethod = context.toMethodWalker(it.method)
|
||||
.nextMethod(it.scanResult.patternScanResult!!.startIndex + 1, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
videoEndMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->videoEnded()Z
|
||||
move-result v0
|
||||
if-eqz v0, :end
|
||||
return-void
|
||||
""", ExternalLabel("end", getInstruction(0))
|
||||
)
|
||||
}
|
||||
} ?: throw SeekFingerprint.exception
|
||||
} ?: throw PlayerInitFingerprint.exception
|
||||
}
|
||||
} ?: throw VideoEndFingerprint.exception
|
||||
|
||||
/**
|
||||
* Set current video time
|
||||
@ -135,6 +147,7 @@ class VideoIdPatch : BytecodePatch(
|
||||
private lateinit var insertMethod: MutableMethod
|
||||
private lateinit var playerInitMethod: MutableMethod
|
||||
private lateinit var timeMethod: MutableMethod
|
||||
internal lateinit var videoEndMethod: MutableMethod
|
||||
|
||||
/**
|
||||
* Adds an invoke-static instruction, called with the new id when the video changes
|
||||
|
Reference in New Issue
Block a user