Skip to content

Commit

Permalink
fix(YouTube/Shorts components): Hide paused header setting does not…
Browse files Browse the repository at this point in the history
… work
  • Loading branch information
inotia00 committed Oct 3, 2024
1 parent c932956 commit 17cabfb
Showing 1 changed file with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.patches.youtube.video.information.VideoInformationPatch
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.getReference
import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
Expand Down Expand Up @@ -283,15 +284,39 @@ object ShortsComponentPatch : BaseBytecodePatch(

ShortsPausedHeaderFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA

addInstructions(
insertIndex, """
invoke-static {v$insertRegister}, $SHORTS_CLASS_DESCRIPTOR->hideShortsPausedHeader(Z)Z
move-result v$insertRegister
"""
)
val targetIndex = it.scanResult.patternScanResult!!.endIndex + 1
val targetInstruction = getInstruction(targetIndex)
val targetReference =
(targetInstruction as? ReferenceInstruction)?.reference as? MethodReference
val useMethodWalker = targetInstruction.opcode == Opcode.INVOKE_VIRTUAL &&
targetReference?.returnType == "V" &&
targetReference.parameterTypes.firstOrNull() == "Landroid/view/View;"

if (useMethodWalker) {
// YouTube 18.29.38 ~ YouTube 19.28.42
getWalkerMethod(context, targetIndex).apply {
addInstructionsWithLabels(
0, """
invoke-static {}, $SHORTS_CLASS_DESCRIPTOR->hideShortsPausedHeader()Z
move-result v0
if-eqz v0, :show
return-void
""", ExternalLabel("show", getInstruction(0))
)
}
} else {
// YouTube 19.29.42 ~
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val insertRegister =
getInstruction<OneRegisterInstruction>(insertIndex).registerA

addInstructions(
insertIndex, """
invoke-static {v$insertRegister}, $SHORTS_CLASS_DESCRIPTOR->hideShortsPausedHeader(Z)Z
move-result v$insertRegister
"""
)
}
}
}

Expand Down

0 comments on commit 17cabfb

Please sign in to comment.