diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt index 3f6afead3..d24e75585 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/feed/components/FeedComponentsPatch.kt @@ -22,7 +22,7 @@ import app.revanced.patches.youtube.utils.mainactivity.mainActivityResolvePatch import app.revanced.patches.youtube.utils.navigation.navigationBarHookPatch import app.revanced.patches.youtube.utils.patch.PatchList.HIDE_FEED_COMPONENTS import app.revanced.patches.youtube.utils.playertype.playerTypeHookPatch -import app.revanced.patches.youtube.utils.playservice.is_18_34_or_greater +import app.revanced.patches.youtube.utils.playservice.is_19_46_or_greater import app.revanced.patches.youtube.utils.playservice.is_20_02_or_greater import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.resourceid.bar @@ -302,21 +302,35 @@ val feedComponentsPatch = bytecodePatch( reference.returnType.startsWith("L") } - val objectOpcode = if (is_18_34_or_greater) - Opcode.IGET_OBJECT - else - Opcode.MOVE_OBJECT - val objectIndex = indexOfFirstInstructionReversedOrThrow(insertIndex, objectOpcode) - val objectRegister = getInstruction(objectIndex).registerA + if (is_19_46_or_greater) { + val objectIndex = indexOfFirstInstructionReversedOrThrow(insertIndex, Opcode.IGET_OBJECT) + val objectRegister = getInstruction(objectIndex).registerA - addInstructionsWithLabels( - insertIndex, """ - invoke-static {v$objectRegister, p3}, $FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z - move-result v$freeRegister - if-eqz v$freeRegister, :ignore - """ + emptyComponentLabel, - ExternalLabel("ignore", getInstruction(insertIndex)) - ) + addInstructionsWithLabels( + insertIndex, """ + invoke-static {v$objectRegister, p3}, $FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z + move-result v$freeRegister + if-eqz v$freeRegister, :ignore + """ + emptyComponentLabel, + ExternalLabel("ignore", getInstruction(insertIndex)) + ) + } else { + val objectIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_OBJECT) + val objectRegister = getInstruction(objectIndex).registerA + val jumpIndex = it.patternMatch!!.startIndex + + addInstructionsWithLabels( + insertIndex, """ + invoke-static {v$objectRegister, v$freeRegister}, $FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z + move-result v$freeRegister + if-nez v$freeRegister, :filter + """, ExternalLabel("filter", getInstruction(jumpIndex)) + ) + addInstruction( + 0, + "move-object/from16 v$freeRegister, p3" + ) + } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt index 1f971977e..cf1eb8951 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt @@ -33,8 +33,10 @@ val playerResponseMethodHookPatch = bytecodePatch( description = "playerResponseMethodHookPatch" ) { execute { - playerParameterBuilderFingerprint.methodOrThrow().apply { - playerResponseMethod = this + playerResponseMethod = playerParameterBuilderFingerprint.second.methodOrNull + ?: playerParameterBuilderLegacyFingerprint.methodOrThrow() + + playerResponseMethod.apply { parameterIsShortAndOpeningOrPlaying = parameterTypes.indexOfFirst { it == "Z" } + 1 // On some app targets the method has too many registers pushing the parameters past v15. // If needed, move the parameters to 4-bit registers so they can be passed to extension. diff --git a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 35df9a7d1..2f5ce9709 100644 --- a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -426,7 +426,7 @@ SETTINGS: FULLSCREEN_COMPONENTS -->