diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt new file mode 100644 index 00000000..0237c1ec --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/fingerprints/SetSeekbarClickedColorFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.layout.theme.bytecode.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object SetSeekbarClickedColorFingerprint : MethodFingerprint( + opcodes = listOf(Opcode.CONST_HIGH16), + strings = listOf("YOUTUBE", "PREROLL", "POSTROLL") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt index b83c839f..fbc8dcef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/ThemeBytecodePatch.kt @@ -5,6 +5,7 @@ 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.addInstructions import app.revanced.patcher.extensions.instruction import app.revanced.patcher.patch.BytecodePatch @@ -12,9 +13,11 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess 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.layout.theme.annotations.ThemeCompatibility import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint.indexOfInstructionWithSeekbarId +import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.SetSeekbarClickedColorFingerprint import app.revanced.patches.youtube.layout.theme.resource.ThemeResourcePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @@ -25,7 +28,9 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @DependsOn([ThemeLithoComponentsPatch::class, ThemeResourcePatch::class, IntegrationsPatch::class]) @ThemeCompatibility @Version("0.0.1") -class ThemeBytecodePatch : BytecodePatch(listOf(CreateDarkThemeSeekbarFingerprint)) { +class ThemeBytecodePatch : BytecodePatch( + listOf(CreateDarkThemeSeekbarFingerprint, SetSeekbarClickedColorFingerprint) +) { override fun execute(context: BytecodeContext): PatchResult { CreateDarkThemeSeekbarFingerprint.result?.let { val putColorValueIndex = it.method.indexOfInstructionWithSeekbarId!! + 3 @@ -42,6 +47,27 @@ class ThemeBytecodePatch : BytecodePatch(listOf(CreateDarkThemeSeekbarFingerprin ) } } ?: return CreateDarkThemeSeekbarFingerprint.toErrorResult() + + SetSeekbarClickedColorFingerprint.result?.let { result -> + result.mutableMethod.let { + val setColorMethodIndex = result.scanResult.patternScanResult!!.startIndex + 1 + val method = context + .toMethodWalker(it) + .nextMethod(setColorMethodIndex, true) + .getMethod() as MutableMethod + + method.apply { + val colorRegister = (method.instruction(0) as TwoRegisterInstruction).registerA + addInstructions( + 0, + """ + invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarClickedColorValue(I)I + move-result v$colorRegister + """ + ) + } + } + } ?: return SetSeekbarClickedColorFingerprint.toErrorResult() return PatchResultSuccess() }