fix(YouTube - Return YouTube Dislike): Prevent the first Short opened from freezing the UI (#3359)

This commit is contained in:
LisoUseInAIKyrios 2023-12-04 10:47:41 +02:00 committed by GitHub
parent 593e261ce4
commit e024409219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 7 deletions

View File

@ -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.

View File

@ -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

View File

@ -19,7 +19,7 @@ object PlayerResponseMethodHookPatch :
Closeable,
MutableSet<PlayerResponseMethodHookPatch.Hook> 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
"""
)

View File

@ -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.
*

View File

@ -26,7 +26,7 @@
<string name="revanced_ryd_compact_layout_summary_on">Like button styled for minimum width</string>
<string name="revanced_ryd_compact_layout_summary_off">Like button styled for best appearance</string>
<string name="ryd_toast_on_connection_error_title">Show toast if API not available</string>
<string name="ryd_toast_on_connection_error_title">Show toast if API is not available</string>
<string name="ryd_toast_on_connection_error_summary_on">Toast shown if ReturnYouTubeDislike API is not available</string>
<string name="ryd_toast_on_connection_error_summary_off">Toast not shown if ReturnYouTubeDislike API is not available</string>