diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/suggestedvideooverlay/patch/SuggestedVideoOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/suggestedvideooverlay/patch/SuggestedVideoOverlayPatch.kt index 79d7a02da..6a6ca948d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/suggestedvideooverlay/patch/SuggestedVideoOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/suggestedvideooverlay/patch/SuggestedVideoOverlayPatch.kt @@ -7,15 +7,17 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.overlaybutton.general.patch.OverlayButtonsPatch import app.revanced.patches.youtube.player.suggestedvideooverlay.fingerprints.CoreConatinerBuilderFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.fingerprints.VideoEndFingerprint +import app.revanced.patches.youtube.utils.fingerprints.VideoEndParentFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.CoreContainer import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @@ -29,7 +31,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Description("Hide the suggested video overlay to play next.") @DependsOn( [ - OverlayButtonsPatch::class, SettingsPatch::class, SharedResourceIdPatch::class ] @@ -37,7 +38,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @YouTubeCompatibility @Version("0.0.1") class SuggestedVideoOverlayPatch : BytecodePatch( - listOf(CoreConatinerBuilderFingerprint) + listOf( + CoreConatinerBuilderFingerprint, + VideoEndParentFingerprint + ) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -55,11 +59,22 @@ class SuggestedVideoOverlayPatch : BytecodePatch( addInstruction( targetIndex, - "invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR" + "invoke-static {v$targetRegister}, $PLAYER->hideSuggestedVideoOverlay(Landroid/view/ViewGroup;)V" ) } } ?: return CoreConatinerBuilderFingerprint.toErrorResult() + VideoEndParentFingerprint.result?.classDef?.let { classDef -> + VideoEndFingerprint.also { it.resolve(context, classDef) }.result?.let { + it.mutableMethod.apply { + addInstruction( + implementation!!.instructions.size - 1, + "invoke-static {},$PLAYER->hideSuggestedVideoOverlay()V" + ) + } + } ?: return VideoEndFingerprint.toErrorResult() + } ?: return VideoEndParentFingerprint.toErrorResult() + /** * Add settings */