mirror of
https://github.com/revanced/revanced-patches
synced 2024-09-03 04:56:05 +02:00
feat(youtube): bump patches compatibility to v17.49.37
This commit is contained in:
parent
176d34b2ff
commit
83ebc73113
@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patches.shared.fingerprints
|
||||||
|
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object SeekbarFingerprint : MethodFingerprint(
|
||||||
|
"V",
|
||||||
|
strings = listOf("timed_markers_width")
|
||||||
|
)
|
@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patches.shared.fingerprints
|
||||||
|
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object SeekbarOnDrawFingerprint : MethodFingerprint(
|
||||||
|
customFingerprint = { it.name == "onDraw" }
|
||||||
|
)
|
@ -5,18 +5,20 @@ import app.revanced.patcher.annotation.Name
|
|||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility
|
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
|
||||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeCounterFingerprint
|
import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
|
||||||
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.CreateVideoPlayerSeekbarFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
|
||||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
|
import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility
|
||||||
|
import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeCounterFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||||
@ -26,7 +28,7 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class HideTimeAndSeekbarPatch : BytecodePatch(
|
class HideTimeAndSeekbarPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
CreateVideoPlayerSeekbarFingerprint, TimeCounterFingerprint
|
SeekbarFingerprint, TimeCounterFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
@ -40,7 +42,9 @@ class HideTimeAndSeekbarPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val createVideoPlayerSeekbarMethod = CreateVideoPlayerSeekbarFingerprint.result!!.mutableMethod
|
val createVideoPlayerSeekbarMethod = SeekbarFingerprint.result!!.let {
|
||||||
|
SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) }
|
||||||
|
}.result!!.mutableMethod
|
||||||
|
|
||||||
createVideoPlayerSeekbarMethod.addInstructions(
|
createVideoPlayerSeekbarMethod.addInstructions(
|
||||||
0, """
|
0, """
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package app.revanced.patches.youtube.layout.returnyoutubedislike.patch
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
@ -51,8 +52,8 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
|
|||||||
VideoIdPatch.injectCall("Lapp/revanced/integrations/patches/ReturnYouTubeDislikePatch;->newVideoLoaded(Ljava/lang/String;)V")
|
VideoIdPatch.injectCall("Lapp/revanced/integrations/patches/ReturnYouTubeDislikePatch;->newVideoLoaded(Ljava/lang/String;)V")
|
||||||
|
|
||||||
with(TextComponentFingerprint
|
with(TextComponentFingerprint
|
||||||
.also { it.resolve(context, TextComponentSpecParentFingerprint.result!!.classDef) }
|
.apply { resolve(context, TextComponentSpecParentFingerprint.result!!.classDef) }
|
||||||
.result ?: return PatchResultError("Could not find createComponent method")
|
.result ?: return TextComponentFingerprint.toErrorResult()
|
||||||
) {
|
) {
|
||||||
val createComponentMethod = mutableMethod
|
val createComponentMethod = mutableMethod
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints
|
|
||||||
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
object CreateVideoPlayerSeekbarFingerprint : MethodFingerprint(
|
|
||||||
"V",
|
|
||||||
strings = listOf("timed_markers_width")
|
|
||||||
)
|
|
@ -16,12 +16,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
|
||||||
|
import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
|
||||||
|
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||||
import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint
|
import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint
|
||||||
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
|
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
|
||||||
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
|
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
|
||||||
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
|
||||||
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
||||||
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
|
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
|
||||||
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
@ -48,7 +50,7 @@ import org.jf.dexlib2.iface.reference.StringReference
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class SponsorBlockBytecodePatch : BytecodePatch(
|
class SponsorBlockBytecodePatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
CreateVideoPlayerSeekbarFingerprint,
|
SeekbarFingerprint,
|
||||||
NextGenWatchLayoutFingerprint,
|
NextGenWatchLayoutFingerprint,
|
||||||
AppendTimeFingerprint,
|
AppendTimeFingerprint,
|
||||||
PlayerOverlaysLayoutInitFingerprint,
|
PlayerOverlaysLayoutInitFingerprint,
|
||||||
@ -85,7 +87,9 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
/*
|
/*
|
||||||
Seekbar drawing
|
Seekbar drawing
|
||||||
*/
|
*/
|
||||||
val seekbarSignatureResult = CreateVideoPlayerSeekbarFingerprint.result!!
|
val seekbarSignatureResult = SeekbarFingerprint.result!!.let {
|
||||||
|
SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) }
|
||||||
|
}.result!!
|
||||||
val seekbarMethod = seekbarSignatureResult.mutableMethod
|
val seekbarMethod = seekbarSignatureResult.mutableMethod
|
||||||
val seekbarMethodInstructions = seekbarMethod.implementation!!.instructions
|
val seekbarMethodInstructions = seekbarMethod.implementation!!.instructions
|
||||||
|
|
||||||
@ -96,7 +100,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
if (instruction.opcode != Opcode.MOVE_OBJECT_FROM16) continue
|
if (instruction.opcode != Opcode.MOVE_OBJECT_FROM16) continue
|
||||||
seekbarMethod.addInstruction(
|
seekbarMethod.addInstruction(
|
||||||
index + 1,
|
index + 1,
|
||||||
"invoke-static {v0}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V"
|
"invoke-static/range {p0 .. p0}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V"
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -120,10 +124,10 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
/*
|
/*
|
||||||
Set rectangle absolute left and right positions
|
Set rectangle absolute left and right positions
|
||||||
*/
|
*/
|
||||||
val drawRectangleInstructions = seekbarMethodInstructions.filter {
|
val drawRectangleInstructions = seekbarMethodInstructions.withIndex().filter { (_, instruction) ->
|
||||||
it is ReferenceInstruction && (it.reference as? MethodReference)?.name == "drawRect" && it is FiveRegisterInstruction
|
instruction is ReferenceInstruction && (instruction.reference as? MethodReference)?.name == "drawRect"
|
||||||
}.map { // TODO: improve code
|
}.map { (index, instruction) -> // TODO: improve code
|
||||||
seekbarMethodInstructions.indexOf(it) to (it as FiveRegisterInstruction).registerD
|
index to (instruction as FiveRegisterInstruction).registerD
|
||||||
}
|
}
|
||||||
|
|
||||||
val (indexRight, rectangleRightRegister) = drawRectangleInstructions[0]
|
val (indexRight, rectangleRightRegister) = drawRectangleInstructions[0]
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.widesearchbar.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object DrawActionBarFingerprint : MethodFingerprint(
|
||||||
|
"V",
|
||||||
|
AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||||
|
listOf("I", "I"),
|
||||||
|
listOf(
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.CONST,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
),
|
||||||
|
)
|
@ -1,8 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.widesearchbar.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
|
|
||||||
object IsInOfflineModeCheckFingerprint : MethodFingerprint(
|
|
||||||
"L",
|
|
||||||
strings = listOf("bundle_is_in_offline_mode")
|
|
||||||
)
|
|
@ -1,18 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.layout.widesearchbar.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
|
|
||||||
object IsInOfflineModeCheckResultFingerprint : MethodFingerprint(
|
|
||||||
"L",
|
|
||||||
parameters = listOf("L", "L", "L", "L", "L"),
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.INVOKE_STATIC,
|
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.IF_EQZ,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.MOVE_OBJECT,
|
|
||||||
Opcode.MOVE_OBJECT,
|
|
||||||
Opcode.MOVE_OBJECT,
|
|
||||||
),
|
|
||||||
)
|
|
@ -8,7 +8,6 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.data.toMethodWalker
|
import app.revanced.patcher.data.toMethodWalker
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
@ -18,8 +17,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|||||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility
|
import app.revanced.patches.youtube.layout.widesearchbar.annotations.WideSearchbarCompatibility
|
||||||
import app.revanced.patches.youtube.layout.widesearchbar.fingerprints.IsInOfflineModeCheckFingerprint
|
import app.revanced.patches.youtube.layout.widesearchbar.fingerprints.DrawActionBarFingerprint
|
||||||
import app.revanced.patches.youtube.layout.widesearchbar.fingerprints.IsInOfflineModeCheckResultFingerprint
|
|
||||||
import app.revanced.patches.youtube.layout.widesearchbar.fingerprints.SetWordmarkHeaderFingerprint
|
import app.revanced.patches.youtube.layout.widesearchbar.fingerprints.SetWordmarkHeaderFingerprint
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
@ -32,7 +30,7 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class WideSearchbarPatch : BytecodePatch(
|
class WideSearchbarPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
SetWordmarkHeaderFingerprint, IsInOfflineModeCheckFingerprint
|
SetWordmarkHeaderFingerprint, DrawActionBarFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
private companion object {
|
private companion object {
|
||||||
@ -75,16 +73,12 @@ class WideSearchbarPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// resolve fingerprints
|
val result = DrawActionBarFingerprint.result ?: return DrawActionBarFingerprint.toErrorResult()
|
||||||
IsInOfflineModeCheckFingerprint.result?.let {
|
|
||||||
if (!IsInOfflineModeCheckResultFingerprint.resolve(context, it.classDef))
|
|
||||||
return IsInOfflineModeCheckResultFingerprint.toErrorResult()
|
|
||||||
} ?: return IsInOfflineModeCheckFingerprint.toErrorResult()
|
|
||||||
|
|
||||||
// patch methods
|
// patch methods
|
||||||
mapOf(
|
mapOf(
|
||||||
SetWordmarkHeaderFingerprint to 1,
|
SetWordmarkHeaderFingerprint to 1,
|
||||||
IsInOfflineModeCheckResultFingerprint to 0
|
DrawActionBarFingerprint to result.scanResult.patternScanResult!!.endIndex
|
||||||
).forEach { (fingerprint, callIndex) ->
|
).forEach { (fingerprint, callIndex) ->
|
||||||
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
|
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import app.revanced.patches.youtube.misc.litho.filter.fingerprints.EmptyComponen
|
|||||||
import org.jf.dexlib2.iface.instruction.Instruction
|
import org.jf.dexlib2.iface.instruction.Instruction
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import org.jf.dexlib2.iface.reference.FieldReference
|
||||||
import org.jf.dexlib2.iface.reference.MethodReference
|
import org.jf.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
@ -44,14 +45,16 @@ class LithoFilterPatch : BytecodePatch(
|
|||||||
val builderMethodDescriptor = instruction(builderMethodIndex).toDescriptor()
|
val builderMethodDescriptor = instruction(builderMethodIndex).toDescriptor()
|
||||||
val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).toDescriptor()
|
val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).toDescriptor()
|
||||||
|
|
||||||
|
val stringBuilderRegister = (instruction(insertHookIndex - 1) as TwoRegisterInstruction).registerA
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
insertHookIndex, // right after setting the component.pathBuilder field,
|
insertHookIndex, // right after setting the component.pathBuilder field,
|
||||||
"""
|
"""
|
||||||
invoke-static {v5, v2}, Lapp/revanced/integrations/patches/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
|
invoke-static {v$stringBuilderRegister, v0}, Lapp/revanced/integrations/patches/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
|
||||||
move-result v$clobberedRegister
|
move-result v$clobberedRegister
|
||||||
if-eqz v$clobberedRegister, :not_an_ad
|
if-eqz v$clobberedRegister, :not_an_ad
|
||||||
move-object/from16 v2, p1
|
move-object/from16 v0, p1
|
||||||
invoke-static {v2}, $builderMethodDescriptor
|
invoke-static {v0}, $builderMethodDescriptor
|
||||||
move-result-object v0
|
move-result-object v0
|
||||||
iget-object v0, v0, $emptyComponentFieldDescriptor
|
iget-object v0, v0, $emptyComponentFieldDescriptor
|
||||||
return-object v0
|
return-object v0
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
object ThemeConstructorFingerprint : MethodFingerprint(
|
||||||
|
"L",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
|
listOf("L"),
|
||||||
|
strings = listOf("settings.SettingsActivity", ":android:show_fragment", "settings.GeneralPrefsFragment")
|
||||||
|
)
|
@ -6,18 +6,7 @@ import org.jf.dexlib2.AccessFlags
|
|||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
object ThemeSetterAppFingerprint : MethodFingerprint(
|
object ThemeSetterAppFingerprint : MethodFingerprint(
|
||||||
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "L", "L"), listOf(
|
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, opcodes = listOf(
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.IF_EQZ,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.IF_EQZ,
|
|
||||||
Opcode.NEW_INSTANCE,
|
|
||||||
Opcode.INVOKE_INTERFACE,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.SGET_OBJECT,
|
|
||||||
Opcode.IF_NE,
|
|
||||||
Opcode.CONST, //target reference
|
Opcode.CONST, //target reference
|
||||||
Opcode.GOTO,
|
Opcode.GOTO,
|
||||||
Opcode.CONST, //target reference
|
Opcode.CONST, //target reference
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package app.revanced.patches.youtube.misc.settings.bytecode.patch
|
package app.revanced.patches.youtube.misc.settings.bytecode.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
@ -16,6 +18,7 @@ import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen
|
|||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
|
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.LicenseActivityFingerprint
|
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.LicenseActivityFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeConstructorFingerprint
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterAppFingerprint
|
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterAppFingerprint
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterSystemFingerprint
|
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterSystemFingerprint
|
||||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch
|
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch
|
||||||
@ -33,7 +36,7 @@ import org.jf.dexlib2.util.MethodUtil
|
|||||||
@SettingsCompatibility
|
@SettingsCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class SettingsPatch : BytecodePatch(
|
class SettingsPatch : BytecodePatch(
|
||||||
listOf(LicenseActivityFingerprint, ThemeSetterSystemFingerprint, ThemeSetterAppFingerprint)
|
listOf(LicenseActivityFingerprint, ThemeSetterSystemFingerprint, ThemeConstructorFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
fun buildInvokeInstructionsString(
|
fun buildInvokeInstructionsString(
|
||||||
@ -44,48 +47,47 @@ class SettingsPatch : BytecodePatch(
|
|||||||
) = "invoke-static {$registers}, $classDescriptor->$methodName($parameters)V"
|
) = "invoke-static {$registers}, $classDescriptor->$methodName($parameters)V"
|
||||||
|
|
||||||
// apply the current theme of the settings page
|
// apply the current theme of the settings page
|
||||||
with(ThemeSetterSystemFingerprint.result!!) {
|
ThemeSetterSystemFingerprint.result!!.let { result ->
|
||||||
with(mutableMethod) {
|
|
||||||
val call = buildInvokeInstructionsString()
|
val call = buildInvokeInstructionsString()
|
||||||
|
result.mutableMethod.apply {
|
||||||
addInstruction(
|
addInstruction(
|
||||||
scanResult.patternScanResult!!.startIndex,
|
result.scanResult.patternScanResult!!.startIndex, call
|
||||||
call
|
|
||||||
)
|
)
|
||||||
|
addInstructions(
|
||||||
addInstruction(
|
implementation!!.instructions.size - 1, call
|
||||||
mutableMethod.implementation!!.instructions.size - 1,
|
|
||||||
call
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the theme based on the preference of the app
|
// set the theme based on the preference of the app
|
||||||
with(ThemeSetterAppFingerprint.result!!) {
|
with((ThemeConstructorFingerprint.result?.let {
|
||||||
with(mutableMethod) {
|
ThemeSetterAppFingerprint.apply {
|
||||||
|
if (!resolve(context, it.classDef)) return ThemeSetterAppFingerprint.toErrorResult()
|
||||||
|
}
|
||||||
|
} ?: return ThemeConstructorFingerprint.toErrorResult()).result!!) {
|
||||||
fun buildInstructionsString(theme: Int) = """
|
fun buildInstructionsString(theme: Int) = """
|
||||||
const/4 v0, 0x$theme
|
const/4 v0, 0x$theme
|
||||||
${buildInvokeInstructionsString(parameters = "I")}
|
${buildInvokeInstructionsString(parameters = "I")}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
val patternScanResult = scanResult.patternScanResult!!
|
||||||
|
|
||||||
|
mutableMethod.apply {
|
||||||
addInstructions(
|
addInstructions(
|
||||||
scanResult.patternScanResult!!.endIndex + 1,
|
patternScanResult.endIndex + 1, buildInstructionsString(1)
|
||||||
buildInstructionsString(1)
|
|
||||||
)
|
)
|
||||||
addInstructions(
|
addInstructions(
|
||||||
scanResult.patternScanResult!!.endIndex - 7,
|
patternScanResult.endIndex - 7, buildInstructionsString(0)
|
||||||
buildInstructionsString(0)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
scanResult.patternScanResult!!.endIndex - 9,
|
patternScanResult.endIndex - 9, buildInstructionsString(1)
|
||||||
buildInstructionsString(1)
|
|
||||||
)
|
)
|
||||||
addInstructions(
|
addInstructions(
|
||||||
mutableMethod.implementation!!.instructions.size - 2,
|
implementation!!.instructions.size - 2, buildInstructionsString(0)
|
||||||
buildInstructionsString(0)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the theme based on the preference of the device
|
// set the theme based on the preference of the device
|
||||||
@ -100,8 +102,7 @@ class SettingsPatch : BytecodePatch(
|
|||||||
|
|
||||||
// initialize the settings
|
// initialize the settings
|
||||||
addInstructions(
|
addInstructions(
|
||||||
1,
|
1, """
|
||||||
"""
|
|
||||||
${buildSettingsActivityInvokeString()}
|
${buildSettingsActivityInvokeString()}
|
||||||
return-void
|
return-void
|
||||||
"""
|
"""
|
||||||
@ -134,8 +135,7 @@ class SettingsPatch : BytecodePatch(
|
|||||||
fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) =
|
fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) =
|
||||||
SettingsResourcePatch.addPreferenceScreen(preferenceScreen)
|
SettingsResourcePatch.addPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
fun addPreference(preference: Preference) =
|
fun addPreference(preference: Preference) = SettingsResourcePatch.addPreference(preference)
|
||||||
SettingsResourcePatch.addPreference(preference)
|
|
||||||
|
|
||||||
fun renameIntentsTargetPackage(newPackage: String) {
|
fun renameIntentsTargetPackage(newPackage: String) {
|
||||||
SettingsResourcePatch.overrideIntentsTargetPackage = newPackage
|
SettingsResourcePatch.overrideIntentsTargetPackage = newPackage
|
||||||
|
Loading…
Reference in New Issue
Block a user