diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt index 4b26e092..f11b7780 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility @@ -12,21 +12,14 @@ import org.jf.dexlib2.Opcode @MatchingMethod( "LFullscreenEngagementPanelOverlay;", "e" ) -@FuzzyPatternScanMethod(2) +@DirectPatternScanMethod @ShortsButtonCompatibility @Version("0.0.1") object FullscreenViewAdderFingerprint : MethodFingerprint( null, null, - listOf("L", "L"), - listOf( - Opcode.GOTO, - Opcode.IGET_BOOLEAN, - Opcode.IF_EQ, - Opcode.GOTO, - Opcode.CONST_4, - Opcode.INVOKE_VIRTUAL, - ), null, - { it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") } + listOf( + Opcode.IGET_BOOLEAN + ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt new file mode 100644 index 00000000..9073b25e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/fingerprints/FullscreenViewAdderParentFingerprint.kt @@ -0,0 +1,32 @@ +package app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility +import org.jf.dexlib2.Opcode + +@Name("fullscreen-view-adder-parent-fingerprint") +@MatchingMethod( + "LFullscreenEngagementPanelOverlay;", "e" +) +@DirectPatternScanMethod +@ShortsButtonCompatibility +@Version("0.0.1") +object FullscreenViewAdderParentFingerprint : MethodFingerprint( + null, + null, + listOf("L", "L"), + listOf( + Opcode.GOTO, + Opcode.IGET_BOOLEAN, + Opcode.IF_EQ, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.INVOKE_VIRTUAL, + ), + null, + { it.definingClass.endsWith("FullscreenEngagementPanelOverlay;") } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt index 5a1e4603..c00abab1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt @@ -5,6 +5,8 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess @@ -13,9 +15,8 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.fullscreenpanels.annotations.FullscreenPanelsCompatibility import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint +import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderParentFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import org.jf.dexlib2.iface.instruction.ReferenceInstruction -import org.jf.dexlib2.iface.reference.MethodReference @Patch @Name("disable-fullscreen-panels") @@ -25,23 +26,23 @@ import org.jf.dexlib2.iface.reference.MethodReference @Version("0.0.1") class FullscreenPanelsRemoverPatch : BytecodePatch( listOf( - FullscreenViewAdderFingerprint + FullscreenViewAdderParentFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = FullscreenViewAdderFingerprint.result + val parentResult = FullscreenViewAdderParentFingerprint.result!! + FullscreenViewAdderFingerprint.resolve(data, parentResult.method, parentResult.classDef) + val result = FullscreenViewAdderParentFingerprint.result ?: return PatchResultError("Fingerprint not resolved!") val method = result.mutableMethod - val implementation = method.implementation - ?: return PatchResultError("Implementation not found!") - val visibilityCallIndex = implementation.instructions.withIndex() - .first { ((it.value as? ReferenceInstruction)?.reference as? MethodReference)?.name == ("setVisibility") }.index + val ifIndex = result.patternScanResult!!.startIndex + 2 + method.removeInstruction(ifIndex) method.addInstructions( - visibilityCallIndex - 1, """ - invoke-static { }, Lapp/revanced/integrations/patches/FullscreenPanelsRemoverPatch;->getFullsceenPanelsVisibility()I + ifIndex, """ + invoke-static {}, Lapp/revanced/integrations/patches/FullscreenPanelsRemoverPatch;->getFullscreenPanelsVisibility()I move-result p1 """ )