mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(youtube/custom-seekbar-color): apply custom seekbar color to shorts
This commit is contained in:
@ -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;")
|
||||
}
|
||||
)
|
@ -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)
|
||||
}
|
||||
)
|
@ -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)
|
||||
)
|
@ -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
|
||||
)
|
||||
}
|
||||
)
|
@ -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)
|
||||
}
|
||||
)
|
@ -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<TwoRegisterInstruction>(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")
|
||||
|
@ -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")
|
||||
|
Reference in New Issue
Block a user