Skip to content

Commit

Permalink
feat(YouTube - Seekbar components): Add patch options to set Cairo se…
Browse files Browse the repository at this point in the history
…ekbar colors
  • Loading branch information
anddea committed Sep 17, 2024
1 parent fd5b5e6 commit b956855
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ 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.PatchException
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.player.components.PlayerComponentsResourcePatch
import app.revanced.patches.shared.drawable.DrawableColorPatch
import app.revanced.patches.youtube.player.seekbar.fingerprints.CairoSeekbarConfigFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.ControlsOverlayStyleFingerprint
Expand All @@ -29,14 +31,10 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.Inlin
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelTimeBarPlayedColor
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
import app.revanced.patches.youtube.utils.settings.SettingsPatch.updatePatchStatus
import app.revanced.patches.youtube.video.information.VideoInformationPatch
import app.revanced.util.getTargetIndexOrThrow
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.literalInstructionBooleanHook
import app.revanced.util.*
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.dexbacked.reference.DexBackedMethodReference
Expand Down Expand Up @@ -71,6 +69,20 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
TotalTimeFingerprint
)
) {
private val CairoStartColor by stringPatchOption(
key = "CairoStartColor",
default = "#ffff2791",
title = "Cairo start color",
description = "Set Cairo start color for the seekbar."
)

private val CairoEndColor by stringPatchOption(
key = "CairoEndColor",
default = "#ffff0033",
title = "Cairo end color",
description = "Set Cairo end color for the seekbar."
)

override fun execute(context: BytecodeContext) {

var settingArray = arrayOf(
Expand Down Expand Up @@ -201,6 +213,19 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
scaleNode.replaceChild(replacementNode, shapeNode)
}

contexts.xmlEditor["res/values/colors.xml"].use { editor ->
editor.file.doRecursively loop@{ node ->
if (node is Element && node.tagName == "color") {
if (node.getAttribute("name") == "yt_youtube_magenta") {
node.textContent = CairoStartColor
}
if (node.getAttribute("name") == "yt_youtube_red_cairo") {
node.textContent = CairoEndColor
}
}
}
}

// endregion

// region patch for hide chapter
Expand Down

0 comments on commit b956855

Please sign in to comment.