fix(youtube/hide-player-buttons): fix previous/next button showing if previous video exists (#2261)

This commit is contained in:
LisoUseInAIKyrios 2023-05-25 21:34:38 +04:00 committed by GitHub
parent 47580a0367
commit 91d1aabd32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,7 @@ class HidePlayerButtonsPatch : BytecodePatch(
) { ) {
private object ParameterOffsets { private object ParameterOffsets {
const val HAS_NEXT = 5 const val HAS_NEXT = 5
const val HAS_PREVIOUS = 6
} }
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
@ -58,13 +59,16 @@ class HidePlayerButtonsPatch : BytecodePatch(
// overriding this parameter register hides the previous and next buttons // overriding this parameter register hides the previous and next buttons
val hasNextParameterRegister = callInstruction.startRegister + ParameterOffsets.HAS_NEXT val hasNextParameterRegister = callInstruction.startRegister + ParameterOffsets.HAS_NEXT
val hasPreviousParameterRegister = callInstruction.startRegister + ParameterOffsets.HAS_PREVIOUS
mutableMethod.addInstructions( mutableMethod.addInstructions(
callIndex, callIndex,
""" """
invoke-static { }, Lapp/revanced/integrations/patches/HidePlayerButtonsPatch;->hideButtons()Z invoke-static { v$hasNextParameterRegister }, Lapp/revanced/integrations/patches/HidePlayerButtonsPatch;->previousOrNextButtonIsVisible(Z)Z
move-result v$hasNextParameterRegister move-result v$hasNextParameterRegister
xor-int/lit8 v$hasNextParameterRegister, v$hasNextParameterRegister, 1
invoke-static { v$hasPreviousParameterRegister }, Lapp/revanced/integrations/patches/HidePlayerButtonsPatch;->previousOrNextButtonIsVisible(Z)Z
move-result v$hasPreviousParameterRegister
""" """
) )
} ?: return PlayerControlsVisibilityModelFingerprint.toErrorResult() } ?: return PlayerControlsVisibilityModelFingerprint.toErrorResult()