diff --git a/README-template.md b/README-template.md index 3501b06ba..4c0c96e66 100644 --- a/README-template.md +++ b/README-template.md @@ -34,7 +34,8 @@ Example: "18.27.36", "18.29.38", "18.30.37", - "18.31.40" + "18.31.40", + "18.32.39" ] } ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotFingerprint.kt index fc02db005..4e7e67c32 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelForcedMuteButton +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPivotButton import app.revanced.util.bytecode.isWideLiteralExists import com.android.tools.smali.dexlib2.AccessFlags @@ -10,5 +10,5 @@ object ShortsPivotFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, parameters = listOf("Z", "Z", "L"), - customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelForcedMuteButton) } + customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelPivotButton) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotLegacyFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotLegacyFingerprint.kt new file mode 100644 index 000000000..23a93c159 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/fingerprints/ShortsPivotLegacyFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.shorts.shortscomponent.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.ReelForcedMuteButton +import app.revanced.util.bytecode.isWideLiteralExists +import com.android.tools.smali.dexlib2.AccessFlags + +object ShortsPivotLegacyFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + parameters = listOf("Z", "Z", "L"), + customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelForcedMuteButton) } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPivotButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPivotButtonPatch.kt index 99812d8e0..e765a59d1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPivotButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsPivotButtonPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.youtube.shorts.shortscomponent.patch import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch @@ -9,17 +10,22 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsPivotFingerprint +import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsPivotLegacyFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelForcedMuteButton +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPivotButton import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SHORTS import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction class ShortsPivotButtonPatch : BytecodePatch( - listOf(ShortsPivotFingerprint) + listOf( + ShortsPivotFingerprint, + ShortsPivotLegacyFingerprint + ) ) { override fun execute(context: BytecodeContext) { - ShortsPivotFingerprint.result?.let { + ShortsPivotLegacyFingerprint.result?.let { it.mutableMethod.apply { val targetIndex = getWideLiteralIndex(ReelForcedMuteButton) val targetRegister = getInstruction(targetIndex).registerA @@ -27,9 +33,6 @@ class ShortsPivotButtonPatch : BytecodePatch( val insertIndex = getTargetIndexDownTo(targetIndex, Opcode.IF_EQZ) val jumpIndex = getTargetIndexUpTo(targetIndex, Opcode.GOTO) - if (insertIndex == -1 || jumpIndex == -1) - throw PatchException("Failed to find hook method") - addInstructionsWithLabels( insertIndex, """ invoke-static {}, $SHORTS->hideShortsPlayerPivotButton()Z @@ -38,9 +41,24 @@ class ShortsPivotButtonPatch : BytecodePatch( """, ExternalLabel("hide", getInstruction(jumpIndex)) ) } + } ?: ShortsPivotFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = getWideLiteralIndex(ReelPivotButton) + + val insertIndex = getTargetIndexDownTo(targetIndex, Opcode.INVOKE_STATIC) + 2 + val insertRegister = getInstruction(insertIndex).registerA + + addInstructions( + insertIndex, """ + invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerPivotButton(Ljava/lang/Object;)Ljava/lang/Object; + move-result-object v$insertRegister + """ + ) + } } ?: throw ShortsPivotFingerprint.exception } + private companion object { fun MutableMethod.getTargetIndexDownTo( startIndex: Int, @@ -52,7 +70,7 @@ class ShortsPivotButtonPatch : BytecodePatch( return index } - return -1 + throw PatchException("Failed to find hook method") } fun MutableMethod.getTargetIndexUpTo( @@ -65,7 +83,7 @@ class ShortsPivotButtonPatch : BytecodePatch( return index } - return -1 + throw PatchException("Failed to find hook method") } } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt index 061a8b07c..cd99efdd7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt @@ -18,7 +18,8 @@ import app.revanced.patcher.annotation.Package "18.27.36", "18.29.38", "18.30.37", - "18.31.40" + "18.31.40", + "18.32.39" ) ) ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt index 491722630..c45981603 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -59,6 +59,7 @@ class SharedResourceIdPatch : ResourcePatch { var ReelDynRemix: Long = -1 var ReelDynShare: Long = -1 var ReelForcedMuteButton: Long = -1 + var ReelPivotButton: Long = -1 var ReelPlayerBadge: Long = -1 var ReelPlayerBadge2: Long = -1 var ReelPlayerFooter: Long = -1 @@ -139,6 +140,7 @@ class SharedResourceIdPatch : ResourcePatch { ReelDynRemix = find(ID, "reel_dyn_remix") ReelDynShare = find(ID, "reel_dyn_share") ReelForcedMuteButton = find(ID, "reel_player_forced_mute_button") + ReelPivotButton = find(ID, "reel_pivot_button") ReelPlayerBadge = find(ID, "reel_player_badge") ReelPlayerBadge2 = find(ID, "reel_player_badge2") ReelPlayerFooter = find(LAYOUT, "reel_player_dyn_footer_vert_stories3")