diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt index 3c57953da9..830fd0f367 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ControlsOverlayStyleFingerprint.kt @@ -4,6 +4,9 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode object ControlsOverlayStyleFingerprint : MethodFingerprint( - opcodes = listOf(Opcode.IGET_BOOLEAN), - strings = listOf("supportsNextPrevious", "Missing required properties:") + opcodes = listOf(Opcode.CONST_HIGH16), + strings = listOf("YOUTUBE", "PREROLL", "POSTROLL"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("/ControlsOverlayStyle;") + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/PlayerSeekbarColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/PlayerSeekbarColorFingerprint.kt new file mode 100644 index 0000000000..d9b6031bc0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/PlayerSeekbarColorFingerprint.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.youtube.seekbar.seekbarcolor.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.InlineTimeBarColorizedBarPlayedColorDark +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarPlayedNotHighlightedColor +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.AccessFlags + +object PlayerSeekbarColorFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + customFingerprint = { methodDef, _ -> + methodDef.isWideLiteralExists(InlineTimeBarColorizedBarPlayedColorDark) + && methodDef.isWideLiteralExists(InlineTimeBarPlayedNotHighlightedColor) + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ProgressColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ProgressColorFingerprint.kt deleted file mode 100644 index 880029d352..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ProgressColorFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object ProgressColorFingerprint : MethodFingerprint( - returnType = "V", - parameters = listOf("I"), - opcodes = listOf(Opcode.OR_INT_LIT8) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/SeekbarColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/SeekbarColorFingerprint.kt deleted file mode 100644 index 4eee79480c..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/SeekbarColorFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark -import app.revanced.util.bytecode.isWideLiteralExists - -object SeekbarColorFingerprint : MethodFingerprint( - customFingerprint = { methodDef, _ -> - methodDef.isWideLiteralExists( - InlineTimeBarColorizedBarPlayedColorDark - ) - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ShortsSeekbarColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ShortsSeekbarColorFingerprint.kt new file mode 100644 index 0000000000..5e7c468b51 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/ShortsSeekbarColorFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.youtube.seekbar.seekbarcolor.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.ReelTimeBarPlayedColor +import app.revanced.util.bytecode.isWideLiteralExists +import org.jf.dexlib2.AccessFlags + +object ShortsSeekbarColorFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + customFingerprint = { methodDef, _ -> + methodDef.isWideLiteralExists(ReelTimeBarPlayedColor) + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt index 5e57f4e2ee..928f5967be 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.toMethodWalker import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError @@ -16,18 +16,20 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ControlsOverlayStyleFingerprint -import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ProgressColorFingerprint -import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.SeekbarColorFingerprint +import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.PlayerSeekbarColorFingerprint +import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ShortsSeekbarColorFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.litho.patch.LithoThemePatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarPlayedNotHighlightedColor +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelTimeBarPlayedColor import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch.Companion.contexts import app.revanced.util.bytecode.getWideLiteralIndex import app.revanced.util.integrations.Constants.SEEKBAR import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.w3c.dom.Element @Patch @@ -45,29 +47,36 @@ import org.w3c.dom.Element class SeekbarColorPatch : BytecodePatch( listOf( ControlsOverlayStyleFingerprint, - SeekbarColorFingerprint + PlayerSeekbarColorFingerprint, + ShortsSeekbarColorFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { - SeekbarColorFingerprint.result?.let { - it.mutableMethod.apply { - hook(getWideLiteralIndex(InlineTimeBarColorizedBarPlayedColorDark) + 2) - hook(getWideLiteralIndex(InlineTimeBarPlayedNotHighlightedColor) + 2) - } - } ?: return SeekbarColorFingerprint.toErrorResult() + PlayerSeekbarColorFingerprint.result?.mutableMethod?.apply { + hook(getWideLiteralIndex(InlineTimeBarColorizedBarPlayedColorDark) + 2) + hook(getWideLiteralIndex(InlineTimeBarPlayedNotHighlightedColor) + 2) + } ?: return PlayerSeekbarColorFingerprint.toErrorResult() - ControlsOverlayStyleFingerprint.result?.let { parentResult -> - ProgressColorFingerprint.also { - it.resolve( - context, - parentResult.classDef - ) - }.result?.mutableMethod?.addInstructions( - 0, """ - invoke-static {p1}, $SEEKBAR->getSeekbarClickedColorValue(I)I - move-result p1 + ShortsSeekbarColorFingerprint.result?.mutableMethod?.apply { + hook(getWideLiteralIndex(ReelTimeBarPlayedColor) + 2) + } ?: return ShortsSeekbarColorFingerprint.toErrorResult() + + ControlsOverlayStyleFingerprint.result?.let { + with( + context + .toMethodWalker(it.method) + .nextMethod(it.scanResult.patternScanResult!!.startIndex + 1, true) + .getMethod() as MutableMethod + ) { + val colorRegister = getInstruction(0).registerA + + addInstructions( + 0, """ + invoke-static {v$colorRegister}, $SEEKBAR->getSeekbarClickedColorValue(I)I + move-result v$colorRegister """ - ) ?: return ProgressColorFingerprint.toErrorResult() + ) + } } ?: return ControlsOverlayStyleFingerprint.toErrorResult() LithoThemePatch.injectCall("$SEEKBAR->getLithoColor(I)I") 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 7551fae979..bcc7c30564 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 @@ -64,6 +64,7 @@ class SharedResourceIdPatch : ResourcePatch { var ReelPlayerPausedStateButton: Long = -1 var ReelRightDislikeIcon: Long = -1 var ReelRightLikeIcon: Long = -1 + var ReelTimeBarPlayedColor: Long = -1 var RelatedChipCloudMargin: Long = -1 var RightComment: Long = -1 var ScrimOverlay: Long = -1 @@ -137,6 +138,7 @@ class SharedResourceIdPatch : ResourcePatch { ReelPlayerPausedStateButton = find(ID, "reel_player_paused_state_buttons") ReelRightDislikeIcon = find(DRAWABLE, "reel_right_dislike_icon") ReelRightLikeIcon = find(DRAWABLE, "reel_right_like_icon") + ReelTimeBarPlayedColor = find(COLOR, "reel_time_bar_played_color") RelatedChipCloudMargin = find(LAYOUT, "related_chip_cloud_reduced_margins") RightComment = find(DRAWABLE, "ic_right_comment_32c") ScrimOverlay = find(ID, "scrim_overlay")