mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(YouTube - Shorts components): add Change Shorts background repeat state
setting (YouTube 19.34.42+)
This commit is contained in:
@ -56,6 +56,7 @@ internal val reelEnumConstructorFingerprint = legacyFingerprint(
|
||||
name = "reelEnumConstructorFingerprint",
|
||||
returnType = "V",
|
||||
strings = listOf(
|
||||
"REEL_LOOP_BEHAVIOR_UNKNOWN",
|
||||
"REEL_LOOP_BEHAVIOR_SINGLE_PLAY",
|
||||
"REEL_LOOP_BEHAVIOR_REPEAT",
|
||||
"REEL_LOOP_BEHAVIOR_END_SCREEN"
|
||||
|
@ -13,6 +13,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.litho.addLithoFilter
|
||||
import app.revanced.patches.shared.litho.lithoFilterPatch
|
||||
import app.revanced.patches.shared.mainactivity.injectOnCreateMethodCall
|
||||
import app.revanced.patches.shared.textcomponent.hookSpannableString
|
||||
import app.revanced.patches.shared.textcomponent.textComponentPatch
|
||||
import app.revanced.patches.youtube.utils.bottomSheetMenuItemBuilderFingerprint
|
||||
@ -24,16 +25,17 @@ import app.revanced.patches.youtube.utils.extension.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.indexOfSpannedCharSequenceInstruction
|
||||
import app.revanced.patches.youtube.utils.lottie.LOTTIE_ANIMATION_VIEW_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.lottie.lottieAnimationViewHookPatch
|
||||
import app.revanced.patches.youtube.utils.mainactivity.mainActivityResolvePatch
|
||||
import app.revanced.patches.youtube.utils.navigation.addBottomBarContainerHook
|
||||
import app.revanced.patches.youtube.utils.navigation.navigationBarHookPatch
|
||||
import app.revanced.patches.youtube.utils.patch.PatchList.SHORTS_COMPONENTS
|
||||
import app.revanced.patches.youtube.utils.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.playservice.is_18_31_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_18_34_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_18_49_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_02_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_28_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.bottomSheetRecyclerViewHook
|
||||
import app.revanced.patches.youtube.utils.recyclerview.bottomSheetRecyclerViewPatch
|
||||
@ -67,6 +69,7 @@ import app.revanced.util.cloneMutable
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.findMutableMethodOf
|
||||
import app.revanced.util.fingerprint.definingClassOrThrow
|
||||
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
|
||||
import app.revanced.util.fingerprint.matchOrThrow
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
@ -368,25 +371,34 @@ private val shortsNavigationBarPatch = bytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
private const val EXTENSION_REPEAT_STATE_CLASS_DESCRIPTOR =
|
||||
"$SHORTS_PATH/ShortsRepeatStatePatch;"
|
||||
|
||||
private val shortsRepeatPatch = bytecodePatch(
|
||||
description = "shortsRepeatPatch"
|
||||
) {
|
||||
execute {
|
||||
reelEnumConstructorFingerprint.methodOrThrow().apply {
|
||||
arrayOf(
|
||||
"REEL_LOOP_BEHAVIOR_END_SCREEN" to "endScreen",
|
||||
"REEL_LOOP_BEHAVIOR_REPEAT" to "repeat",
|
||||
"REEL_LOOP_BEHAVIOR_SINGLE_PLAY" to "singlePlay"
|
||||
).map { (enumName, fieldName) ->
|
||||
val stringIndex = indexOfFirstStringInstructionOrThrow(enumName)
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(stringIndex, Opcode.SPUT_OBJECT)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
dependsOn(mainActivityResolvePatch)
|
||||
|
||||
addInstruction(
|
||||
insertIndex + 1,
|
||||
"sput-object v$insertRegister, $SHORTS_CLASS_DESCRIPTOR->$fieldName:Ljava/lang/Enum;"
|
||||
)
|
||||
}
|
||||
injectOnCreateMethodCall(
|
||||
EXTENSION_REPEAT_STATE_CLASS_DESCRIPTOR,
|
||||
"setMainActivity"
|
||||
)
|
||||
|
||||
val reelEnumClass = reelEnumConstructorFingerprint.definingClassOrThrow()
|
||||
|
||||
reelEnumConstructorFingerprint.methodOrThrow().apply {
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN_VOID)
|
||||
|
||||
addInstructions(
|
||||
insertIndex,
|
||||
"""
|
||||
# Pass the first enum value to extension.
|
||||
# Any enum value of this type will work.
|
||||
sget-object v0, $reelEnumClass->a:$reelEnumClass
|
||||
invoke-static { v0 }, $EXTENSION_REPEAT_STATE_CLASS_DESCRIPTOR->setYTShortsRepeatEnum(Ljava/lang/Enum;)V
|
||||
""",
|
||||
)
|
||||
|
||||
val endScreenStringIndex =
|
||||
indexOfFirstStringInstructionOrThrow("REEL_LOOP_BEHAVIOR_END_SCREEN")
|
||||
@ -426,7 +438,7 @@ private val shortsRepeatPatch = bytecodePatch(
|
||||
|
||||
addInstructions(
|
||||
index + 2, """
|
||||
invoke-static {v$register}, $SHORTS_CLASS_DESCRIPTOR->changeShortsRepeatState(Ljava/lang/Enum;)Ljava/lang/Enum;
|
||||
invoke-static {v$register}, $EXTENSION_REPEAT_STATE_CLASS_DESCRIPTOR->changeShortsRepeatBehavior(Ljava/lang/Enum;)Ljava/lang/Enum;
|
||||
move-result-object v$register
|
||||
"""
|
||||
)
|
||||
@ -617,6 +629,10 @@ val shortsComponentPatch = bytecodePatch(
|
||||
settingArray += "SETTINGS: SHORTS_CUSTOM_ACTIONS_FLYOUT_MENU"
|
||||
}
|
||||
|
||||
if (is_19_34_or_greater) {
|
||||
settingArray += "SETTINGS: SHORTS_REPEAT_STATE_BACKGROUND"
|
||||
}
|
||||
|
||||
// region patch for hide comments button (non-litho)
|
||||
|
||||
shortsButtonFingerprint.hideButton(rightComment, "hideShortsCommentsButton", false)
|
||||
|
Reference in New Issue
Block a user