fix(YouTube): some patches failed in support version

This commit is contained in:
inotia00 2024-04-29 19:38:11 +09:00
parent f66ac24f55
commit 8417398042
3 changed files with 16 additions and 6 deletions

View File

@ -219,7 +219,11 @@ object PlayerComponentsPatch : BaseBytecodePatch(
val constIndex = getWideLiteralInstructionIndex(FadeDurationFast)
val constRegister = getInstruction<OneRegisterInstruction>(constIndex).registerA
val insertIndex = getTargetIndexReversed(constIndex, Opcode.INVOKE_VIRTUAL) + 1
val jumpIndex = getTargetIndex(insertIndex, Opcode.GOTO).coerceAtMost(getTargetIndex(insertIndex, Opcode.GOTO_16))
val jumpIndex = implementation!!.instructions.let { instruction ->
insertIndex + instruction.subList(insertIndex, instruction.size - 1).indexOfFirst { instructions ->
instructions.opcode == Opcode.GOTO || instructions.opcode == Opcode.GOTO_16
}
}
val replaceInstruction = getInstruction<TwoRegisterInstruction>(insertIndex)
val replaceReference =
@ -284,8 +288,14 @@ object PlayerComponentsPatch : BaseBytecodePatch(
val onClickListenerIndex = getTargetIndexWithMethodReferenceName(insertIndex, "setOnClickListener")
val constComponent = getConstComponent(insertIndex, onClickListenerIndex - 1)
if (constComponent.isNotEmpty()) {
addInstruction(
onClickListenerIndex + 2,
constComponent
)
}
addInstructionsWithLabels(
insertIndex, constComponent + """
insertIndex, """
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->hideSeekUndoMessage()Z
move-result v$insertRegister
if-nez v$insertRegister, :default
@ -387,7 +397,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
for (index in endIndex downTo startIndex) {
val instruction = getInstruction(index)
if (instruction !is WideLiteralInstruction)
if (instruction.opcode != Opcode.CONST_16 && instruction.opcode != Opcode.CONST_4)
continue
if ((instruction as OneRegisterInstruction).registerA != constRegister)

View File

@ -14,7 +14,7 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomSheetFooterText
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.literalInstructionBooleanHook
import app.revanced.util.literalInstructionViewHook
import app.revanced.util.literalInstructionHook
import app.revanced.util.patch.BaseBytecodePatch
@Suppress("unused")
@ -45,7 +45,7 @@ object PlayerFlyoutMenuPatch : BaseBytecodePatch(
CaptionsBottomSheetFingerprint to "hideFooterCaptions",
QualityMenuViewInflateFingerprint to "hideFooterQuality"
).map { (fingerprint, name) ->
fingerprint.literalInstructionViewHook(BottomSheetFooterText, "$PLAYER_CLASS_DESCRIPTOR->$name(Landroid/view/View;)V")
fingerprint.literalInstructionHook(BottomSheetFooterText, "$PLAYER_CLASS_DESCRIPTOR->$name(Landroid/view/View;)V")
}
LithoFilterPatch.addFilter(PANELS_FILTER_CLASS_DESCRIPTOR)