mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-28 03:25:50 +01:00
feat(youtube/theme): theme seekbar when clicked
This commit is contained in:
parent
784e5fb0c7
commit
691a231d99
@ -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")
|
||||
)
|
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user