mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
feat(YouTube - Shorts components): Add Open Shorts in regular player
setting
This commit is contained in:
@ -21,6 +21,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import kotlin.collections.listOf
|
||||
|
||||
internal val bottomSheetMenuListBuilderFingerprint = legacyFingerprint(
|
||||
name = "bottomSheetMenuListBuilderFingerprint",
|
||||
@ -187,3 +188,40 @@ internal val shortsFullscreenFeatureFingerprint = legacyFingerprint(
|
||||
literals = listOf(FULLSCREEN_FEATURE_FLAG),
|
||||
)
|
||||
|
||||
// Pre 19.25
|
||||
internal val shortsPlaybackIntentLegacyFingerprint = legacyFingerprint(
|
||||
name = "shortsPlaybackIntentLegacyFingerprint",
|
||||
returnType = "V",
|
||||
parameters = listOf(
|
||||
"L",
|
||||
"Ljava/util/Map;",
|
||||
"J",
|
||||
"Ljava/lang/String;",
|
||||
"Z",
|
||||
"Ljava/util/Map;"
|
||||
),
|
||||
strings = listOf(
|
||||
// None of these strings are unique.
|
||||
"com.google.android.apps.youtube.app.endpoint.flags",
|
||||
"ReelWatchFragmentArgs",
|
||||
"reels_fragment_descriptor"
|
||||
)
|
||||
)
|
||||
|
||||
internal val shortsPlaybackIntentFingerprint = legacyFingerprint(
|
||||
name = "shortsPlaybackIntentFingerprint",
|
||||
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL,
|
||||
returnType = "V",
|
||||
parameters = listOf(
|
||||
"Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;",
|
||||
"Ljava/util/Map;",
|
||||
"J",
|
||||
"Ljava/lang/String;"
|
||||
),
|
||||
strings = listOf(
|
||||
// None of these strings are unique.
|
||||
"com.google.android.apps.youtube.app.endpoint.flags",
|
||||
"ReelWatchFragmentArgs",
|
||||
"reels_fragment_descriptor"
|
||||
)
|
||||
)
|
||||
|
@ -62,6 +62,9 @@ import app.revanced.patches.youtube.utils.toolbar.hookToolBar
|
||||
import app.revanced.patches.youtube.utils.toolbar.toolBarHookPatch
|
||||
import app.revanced.patches.youtube.video.information.hookShortsVideoInformation
|
||||
import app.revanced.patches.youtube.video.information.videoInformationPatch
|
||||
import app.revanced.patches.youtube.video.playbackstart.PLAYBACK_START_DESCRIPTOR_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.video.playbackstart.playbackStartDescriptorPatch
|
||||
import app.revanced.patches.youtube.video.playbackstart.playbackStartVideoIdReference
|
||||
import app.revanced.patches.youtube.video.videoid.hookPlayerResponseVideoId
|
||||
import app.revanced.patches.youtube.video.videoid.videoIdPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
@ -569,6 +572,8 @@ val shortsComponentPatch = bytecodePatch(
|
||||
shortsToolBarPatch,
|
||||
|
||||
lithoFilterPatch,
|
||||
navigationBarHookPatch,
|
||||
playbackStartDescriptorPatch,
|
||||
playerTypeHookPatch,
|
||||
sharedResourceIdPatch,
|
||||
textComponentPatch,
|
||||
@ -874,6 +879,47 @@ val shortsComponentPatch = bytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for open Shorts in regular player
|
||||
|
||||
fun extensionInstructions(playbackStartRegister: Int, freeRegister: Int) =
|
||||
"""
|
||||
invoke-virtual { v$playbackStartRegister }, $playbackStartVideoIdReference
|
||||
move-result-object v$freeRegister
|
||||
invoke-static { v$freeRegister }, $SHORTS_CLASS_DESCRIPTOR->openShortInRegularPlayer(Ljava/lang/String;)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :disabled
|
||||
return-void
|
||||
:disabled
|
||||
nop
|
||||
"""
|
||||
|
||||
if (!is_19_25_or_greater) {
|
||||
shortsPlaybackIntentLegacyFingerprint.methodOrThrow().apply {
|
||||
val index = indexOfFirstInstructionOrThrow {
|
||||
getReference<MethodReference>()?.returnType == PLAYBACK_START_DESCRIPTOR_CLASS_DESCRIPTOR
|
||||
}
|
||||
val freeRegister = getInstruction<FiveRegisterInstruction>(index).registerC
|
||||
val playbackStartRegister = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
||||
|
||||
addInstructionsWithLabels(
|
||||
index + 2,
|
||||
extensionInstructions(playbackStartRegister, freeRegister)
|
||||
)
|
||||
}
|
||||
|
||||
return@execute
|
||||
}
|
||||
|
||||
shortsPlaybackIntentFingerprint.methodOrThrow().addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
move-object/from16 v0, p1
|
||||
${extensionInstructions(0, 1)}
|
||||
"""
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
addLithoFilter(BUTTON_FILTER_CLASS_DESCRIPTOR)
|
||||
addLithoFilter(SHELF_FILTER_CLASS_DESCRIPTOR)
|
||||
addLithoFilter(RETURN_YOUTUBE_CHANNEL_NAME_FILTER_CLASS_DESCRIPTOR)
|
||||
|
Reference in New Issue
Block a user