diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt index 2b28869af..fda878487 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt @@ -112,7 +112,7 @@ object SpoofSignaturePatch : BytecodePatch( // Hook the player parameters. PlayerResponseMethodHookPatch += PlayerResponseMethodHookPatch.Hook.ProtoBufferParameter( - "$INTEGRATIONS_CLASS_DESCRIPTOR->spoofParameter(Ljava/lang/String;)Ljava/lang/String;" + "$INTEGRATIONS_CLASS_DESCRIPTOR->spoofParameter(Ljava/lang/String;Z)Ljava/lang/String;" ) // Force the seekbar time and chapters to always show up. diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt index b06c4cb9d..1de0f90a3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt @@ -12,6 +12,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.video.information.fingerprints.* +import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch import app.revanced.patches.youtube.video.videoid.VideoIdPatch import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -26,7 +27,7 @@ import com.android.tools.smali.dexlib2.util.MethodUtil @Patch( description = "Hooks YouTube to get information about the current playing video.", - dependencies = [IntegrationsPatch::class, VideoIdPatch::class] + dependencies = [IntegrationsPatch::class, VideoIdPatch::class, PlayerResponseMethodHookPatch::class] ) object VideoInformationPatch : BytecodePatch( setOf( @@ -115,6 +116,10 @@ object VideoInformationPatch : BytecodePatch( VideoIdPatch.hookBackgroundPlayVideoId(videoIdMethodDescriptor) VideoIdPatch.hookPlayerResponseVideoId( "$INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerResponseVideoId(Ljava/lang/String;Z)V") + // Call before any other video id hooks, + // so they can use VideoInformation and check if the video id is for a Short. + PlayerResponseMethodHookPatch += PlayerResponseMethodHookPatch.Hook.ProtoBufferParameterBeforeVideoId( + "$INTEGRATIONS_CLASS_DESCRIPTOR->newPlayerResponseSignature(Ljava/lang/String;Z)Ljava/lang/String;") /* * Set the video time method diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt index 352d88865..3811b761f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt @@ -19,7 +19,7 @@ object PlayerResponseMethodHookPatch : Closeable, MutableSet by mutableSetOf() { private const val VIDEO_ID_PARAMETER = 1 - private const val VIDEO_IS_OPENING_OR_PLAYING_PARAMETER = 11 + private const val IS_SHORT_AND_OPENING_OR_PLAYING_PARAMETER = 11 private const val PROTO_BUFFER_PARAMETER_PARAMETER = 3 private lateinit var playerResponseMethod: MutableMethod @@ -31,13 +31,13 @@ object PlayerResponseMethodHookPatch : override fun close() { fun hookVideoId(hook: Hook) = playerResponseMethod.addInstruction( - 0, "invoke-static {p$VIDEO_ID_PARAMETER, p$VIDEO_IS_OPENING_OR_PLAYING_PARAMETER}, $hook" + 0, "invoke-static {p$VIDEO_ID_PARAMETER, p$IS_SHORT_AND_OPENING_OR_PLAYING_PARAMETER}, $hook" ) fun hookProtoBufferParameter(hook: Hook) = playerResponseMethod.addInstructions( 0, """ - invoke-static {p$PROTO_BUFFER_PARAMETER_PARAMETER}, $hook + invoke-static {p$PROTO_BUFFER_PARAMETER_PARAMETER, p$IS_SHORT_AND_OPENING_OR_PLAYING_PARAMETER}, $hook move-result-object p$PROTO_BUFFER_PARAMETER_PARAMETER """ ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt index eb517a6f2..63295cb8f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt @@ -104,7 +104,7 @@ object VideoIdPatch : BytecodePatch( * Supports all videos and functions in all situations. * * First parameter is the video id. - * Second parameter is if the video is being opened or is currently playing. + * Second parameter is if the video is a Short AND it is being opened or is currently playing. * * Hook is always called off the main thread. * diff --git a/src/main/resources/returnyoutubedislike/host/values/strings.xml b/src/main/resources/returnyoutubedislike/host/values/strings.xml index 6cfedd26d..3502b9399 100644 --- a/src/main/resources/returnyoutubedislike/host/values/strings.xml +++ b/src/main/resources/returnyoutubedislike/host/values/strings.xml @@ -26,7 +26,7 @@ Like button styled for minimum width Like button styled for best appearance - Show toast if API not available + Show toast if API is not available Toast shown if ReturnYouTubeDislike API is not available Toast not shown if ReturnYouTubeDislike API is not available