From afbcf3d90fd2439e5a03528c4efdec3cc06f12d9 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 8 Nov 2025 22:06:54 +0200 Subject: [PATCH] fix exit fullscreen patch --- .../player/fullscreen/ExitFullscreenPatch.kt | 17 ++++++++--------- .../youtube/video/information/Fingerprints.kt | 16 ++++++++++++++++ .../video/information/VideoInformationPatch.kt | 6 ++++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt index 3a1461e0b..2f9e701c5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt @@ -9,8 +9,8 @@ import app.revanced.patches.youtube.misc.playercontrols.playerControlsPatch import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch -import app.revanced.patches.youtube.shared.loopVideoFingerprint -import app.revanced.patches.youtube.shared.loopVideoParentFingerprint +import app.revanced.patches.youtube.video.information.videoEndMethod +import app.revanced.patches.youtube.video.information.videoInformationPatch import app.revanced.util.addInstructionsAtControlFlowLabel @Suppress("unused") @@ -32,7 +32,8 @@ internal val exitFullscreenPatch = bytecodePatch( settingsPatch, addResourcesPatch, playerTypeHookPatch, - playerControlsPatch + playerControlsPatch, + videoInformationPatch ) // Cannot declare as top level since this patch is in the same package as @@ -48,11 +49,9 @@ internal val exitFullscreenPatch = bytecodePatch( ListPreference("revanced_exit_fullscreen") ) - loopVideoFingerprint.match(loopVideoParentFingerprint.originalClassDef).method.apply { - addInstructionsAtControlFlowLabel( - implementation!!.instructions.lastIndex, - "invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->endOfVideoReached()V", - ) - } + videoEndMethod.addInstructionsAtControlFlowLabel( + 0, + "invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->endOfVideoReached()V", + ) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt index b28b6fbf8..98a292358 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt @@ -2,6 +2,8 @@ package app.revanced.patches.youtube.video.information import app.revanced.patcher.fieldAccess import app.revanced.patcher.fingerprint +import app.revanced.patcher.literal +import app.revanced.patcher.methodCall import app.revanced.patcher.string import app.revanced.patches.youtube.shared.videoQualityChangedFingerprint import app.revanced.util.getReference @@ -118,6 +120,20 @@ internal val seekRelativeFingerprint = fingerprint { ) } +internal val videoEndFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("Z") + parameters("J", "L") + instructions( + methodCall( + parameters = listOf(), + returnType = "V" + ), + literal(45368273L, maxAfter = 5), + string("Attempting to seek when video is not playing"), + ) +} + /** * Resolves with the class found in [videoQualityChangedFingerprint]. */ diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt index 05738010c..b09a2dccb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt @@ -70,6 +70,8 @@ private var speedSelectionValueRegister = -1 private lateinit var setPlaybackSpeedMethod: MutableMethod private var setPlaybackSpeedMethodIndex = -1 +internal lateinit var videoEndMethod: MutableMethod + // Used by other patches. internal lateinit var setPlaybackSpeedContainerClassFieldReference: FieldReference private set @@ -143,6 +145,10 @@ val videoInformationPatch = bytecodePatch( } } + videoEndFingerprint.let { + videoEndMethod = navigate(it.originalMethod).to(it.instructionMatches[0].index).stop() + } + /* * Inject call for video ids */