mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 23:54:33 +02:00
fix(YouTube/Hook download actions): Override playlist download button
setting does not work in Download playlist
menu of flyout panel
This commit is contained in:
parent
9b91b3c7e5
commit
09d07ba5a9
@ -10,6 +10,7 @@ import app.revanced.patcher.util.smali.ExternalLabel
|
|||||||
import app.revanced.patches.youtube.general.downloads.fingerprints.AccessibilityOfflineButtonSyncFingerprint
|
import app.revanced.patches.youtube.general.downloads.fingerprints.AccessibilityOfflineButtonSyncFingerprint
|
||||||
import app.revanced.patches.youtube.general.downloads.fingerprints.DownloadPlaylistButtonOnClickFingerprint
|
import app.revanced.patches.youtube.general.downloads.fingerprints.DownloadPlaylistButtonOnClickFingerprint
|
||||||
import app.revanced.patches.youtube.general.downloads.fingerprints.DownloadPlaylistButtonOnClickFingerprint.indexOfPlaylistDownloadActionInvokeInstruction
|
import app.revanced.patches.youtube.general.downloads.fingerprints.DownloadPlaylistButtonOnClickFingerprint.indexOfPlaylistDownloadActionInvokeInstruction
|
||||||
|
import app.revanced.patches.youtube.general.downloads.fingerprints.OfflinePlaylistEndpointFingerprint
|
||||||
import app.revanced.patches.youtube.general.downloads.fingerprints.OfflineVideoEndpointFingerprint
|
import app.revanced.patches.youtube.general.downloads.fingerprints.OfflineVideoEndpointFingerprint
|
||||||
import app.revanced.patches.youtube.general.downloads.fingerprints.SetPlaylistDownloadButtonVisibilityFingerprint
|
import app.revanced.patches.youtube.general.downloads.fingerprints.SetPlaylistDownloadButtonVisibilityFingerprint
|
||||||
import app.revanced.patches.youtube.utils.compatibility.Constants
|
import app.revanced.patches.youtube.utils.compatibility.Constants
|
||||||
@ -25,6 +26,8 @@ import app.revanced.util.resultOrThrow
|
|||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@ -40,12 +43,16 @@ object DownloadActionsPatch : BaseBytecodePatch(
|
|||||||
fingerprints = setOf(
|
fingerprints = setOf(
|
||||||
AccessibilityOfflineButtonSyncFingerprint,
|
AccessibilityOfflineButtonSyncFingerprint,
|
||||||
DownloadPlaylistButtonOnClickFingerprint,
|
DownloadPlaylistButtonOnClickFingerprint,
|
||||||
|
OfflinePlaylistEndpointFingerprint,
|
||||||
OfflineVideoEndpointFingerprint,
|
OfflineVideoEndpointFingerprint,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
"$GENERAL_PATH/DownloadActionsPatch;"
|
"$GENERAL_PATH/DownloadActionsPatch;"
|
||||||
|
|
||||||
|
private const val OFFLINE_PLAYLIST_ENDPOINT_OUTER_CLASS_DESCRIPTOR =
|
||||||
|
"Lcom/google/protos/youtube/api/innertube/OfflinePlaylistEndpointOuterClass${'$'}OfflinePlaylistEndpoint;"
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
// region patch for hook download actions (video action bar and flyout panel)
|
// region patch for hook download actions (video action bar and flyout panel)
|
||||||
@ -98,6 +105,46 @@ object DownloadActionsPatch : BaseBytecodePatch(
|
|||||||
)
|
)
|
||||||
} ?: throw PatchException("Could not find class $onClickListenerClass")
|
} ?: throw PatchException("Could not find class $onClickListenerClass")
|
||||||
|
|
||||||
|
OfflinePlaylistEndpointFingerprint.resultOrThrow().mutableMethod.apply {
|
||||||
|
val playlistIdParameter = parameterTypes.indexOf("Ljava/lang/String;") + 1
|
||||||
|
if (playlistIdParameter > 0) {
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
0, """
|
||||||
|
invoke-static {p$playlistIdParameter}, $INTEGRATIONS_CLASS_DESCRIPTOR->inAppPlaylistDownloadMenuOnClick(Ljava/lang/String;)Z
|
||||||
|
move-result v0
|
||||||
|
if-eqz v0, :show_native_downloader
|
||||||
|
return-void
|
||||||
|
""", ExternalLabel("show_native_downloader", getInstruction(0))
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||||
|
|
||||||
|
val playlistIdIndex = indexOfFirstInstructionOrThrow {
|
||||||
|
val reference = getReference<FieldReference>()
|
||||||
|
opcode == Opcode.IGET_OBJECT &&
|
||||||
|
reference?.definingClass == OFFLINE_PLAYLIST_ENDPOINT_OUTER_CLASS_DESCRIPTOR &&
|
||||||
|
reference.type == "Ljava/lang/String;"
|
||||||
|
}
|
||||||
|
val playlistIdReference = getInstruction<ReferenceInstruction>(playlistIdIndex).reference
|
||||||
|
|
||||||
|
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||||
|
opcode == Opcode.CHECK_CAST &&
|
||||||
|
(this as? ReferenceInstruction)?.reference?.toString() == OFFLINE_PLAYLIST_ENDPOINT_OUTER_CLASS_DESCRIPTOR
|
||||||
|
}
|
||||||
|
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
targetIndex + 1, """
|
||||||
|
iget-object v$freeRegister, v$targetRegister, $playlistIdReference
|
||||||
|
invoke-static {v$freeRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->inAppPlaylistDownloadMenuOnClick(Ljava/lang/String;)Z
|
||||||
|
move-result v$freeRegister
|
||||||
|
if-eqz v$freeRegister, :show_native_downloader
|
||||||
|
return-void
|
||||||
|
""", ExternalLabel("show_native_downloader", getInstruction(targetIndex + 1))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region patch for show the playlist download button
|
// region patch for show the playlist download button
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patches.youtube.general.downloads.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
|
internal object OfflinePlaylistEndpointFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
strings = listOf("Object is not an offlineable playlist: ")
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user