feat(youtube): hide-filmstrip-overlay patch is broken on YouTube v18.19.36

This commit is contained in:
inotia00
2023-06-30 00:33:39 +09:00
parent 42689a7da7
commit 2ba97f99bf
2 changed files with 40 additions and 8 deletions

View File

@ -0,0 +1,32 @@
package app.revanced.patches.youtube.player.filmstripoverlay.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YoutubeControlsOverlay
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object YouTubeControlsOverlayWithFixFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.CONST_16,
Opcode.IF_NEZ,
Opcode.IF_NEZ,
Opcode.GOTO,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQ
),
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(
YoutubeControlsOverlay
)
}
)

View File

@ -19,15 +19,15 @@ import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStr
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayInteractionFingerprint import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayInteractionFingerprint
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayParentFingerprint import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayParentFingerprint
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayPreviewFingerprint import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.FilmStripOverlayPreviewFingerprint
import app.revanced.patches.youtube.player.filmstripoverlay.fingerprints.YouTubeControlsOverlayWithFixFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.PLAYER import app.revanced.util.integrations.Constants.PLAYER
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction35c import org.jf.dexlib2.iface.instruction.formats.Instruction35c
import org.jf.dexlib2.iface.reference.MethodReference import org.jf.dexlib2.iface.reference.MethodReference
@ -45,7 +45,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
class HideFilmstripOverlayPatch : BytecodePatch( class HideFilmstripOverlayPatch : BytecodePatch(
listOf( listOf(
FilmStripOverlayParentFingerprint, FilmStripOverlayParentFingerprint,
YouTubeControlsOverlayFingerprint YouTubeControlsOverlayWithFixFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
@ -66,27 +66,27 @@ class HideFilmstripOverlayPatch : BytecodePatch(
} }
} ?: return FilmStripOverlayParentFingerprint.toErrorResult() } ?: return FilmStripOverlayParentFingerprint.toErrorResult()
YouTubeControlsOverlayFingerprint.result?.let { YouTubeControlsOverlayWithFixFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getIndex("bringChildToFront") + 1 val insertIndex = getIndex("bringChildToFront") + 1
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
val jumpIndex = getIndex("setOnClickListener") + 3 val jumpIndex = getIndex("setOnClickListener") + 3
val fixIndex = val fixIndex = it.scanResult.patternScanResult!!.startIndex + 4
implementation!!.instructions.indexOfFirst { instruction -> (instruction as? NarrowLiteralInstruction)?.narrowLiteral == 12 }
val fixRegister = getInstruction<OneRegisterInstruction>(fixIndex).registerA val fixRegister = getInstruction<OneRegisterInstruction>(fixIndex).registerA
val fixValue = getInstruction<WideLiteralInstruction>(fixIndex).wideLiteral.toInt()
addInstructionsWithLabels( addInstructionsWithLabels(
insertIndex, """ insertIndex, """
const/16 v$fixRegister, 0xc const/16 v$fixRegister, $fixValue
invoke-static {}, $PLAYER->hideFilmstripOverlay()Z invoke-static {}, $PLAYER->hideFilmstripOverlay()Z
move-result v$insertRegister move-result v$insertRegister
if-nez v$insertRegister, :hidden if-nez v$insertRegister, :hidden
""", ExternalLabel("hidden", getInstruction(jumpIndex)) """, ExternalLabel("hidden", getInstruction(jumpIndex))
) )
} }
} ?: return YouTubeControlsOverlayFingerprint.toErrorResult() } ?: return YouTubeControlsOverlayWithFixFingerprint.toErrorResult()
/** /**
* Add settings * Add settings