mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
fix(YouTube/Settings): Search bar in settings
can't find RYD
and SponsorBlock
settings
This commit is contained in:
@ -7,7 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver
|
||||
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR
|
||||
import app.revanced.util.deprecatedOrResultOrThrow
|
||||
import app.revanced.util.isDeprecated
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
@ -53,7 +54,9 @@ abstract class BaseIntegrationsPatch(
|
||||
) {
|
||||
|
||||
fun invoke(integrationsDescriptor: String) {
|
||||
deprecatedOrResultOrThrow()?.mutableMethod?.let { method ->
|
||||
if (isDeprecated()) return
|
||||
|
||||
resultOrThrow().mutableMethod.let { method ->
|
||||
val insertIndex = insertIndexResolver(method)
|
||||
val contextRegister = contextRegisterResolver(method)
|
||||
|
||||
|
@ -2,11 +2,11 @@ package app.revanced.patches.youtube.general.spoofappversion
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addEntryValues
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.patch.BaseResourcePatch
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Suppress("DEPRECATION", "unused")
|
||||
@Suppress("unused")
|
||||
object SpoofAppVersionPatch : BaseResourcePatch(
|
||||
name = "Spoof app version",
|
||||
description = "Adds options to spoof the YouTube client version. " +
|
||||
@ -17,31 +17,20 @@ object SpoofAppVersionPatch : BaseResourcePatch(
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE
|
||||
) {
|
||||
private const val ATTRIBUTE_NAME_ENTRIES =
|
||||
"revanced_spoof_app_version_target_entries"
|
||||
|
||||
private const val ATTRIBUTE_NAME_ENTRY_VALUE =
|
||||
"revanced_spoof_app_version_target_entry_values"
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
|
||||
if (SettingsPatch.upward1834) {
|
||||
context.appendChild(
|
||||
arrayOf(
|
||||
"revanced_spoof_app_version_target_entries" to "@string/revanced_spoof_app_version_target_entry_18_33_40",
|
||||
"revanced_spoof_app_version_target_entry_values" to "18.33.40",
|
||||
)
|
||||
)
|
||||
|
||||
context.appendAppVersion("18.33.40")
|
||||
if (SettingsPatch.upward1839) {
|
||||
context.appendChild(
|
||||
arrayOf(
|
||||
"revanced_spoof_app_version_target_entries" to "@string/revanced_spoof_app_version_target_entry_18_38_45",
|
||||
"revanced_spoof_app_version_target_entry_values" to "18.38.45"
|
||||
)
|
||||
)
|
||||
|
||||
context.appendAppVersion("18.38.45")
|
||||
if (SettingsPatch.upward1849) {
|
||||
context.appendChild(
|
||||
arrayOf(
|
||||
"revanced_spoof_app_version_target_entries" to "@string/revanced_spoof_app_version_target_entry_18_48_39",
|
||||
"revanced_spoof_app_version_target_entry_values" to "18.48.39"
|
||||
)
|
||||
)
|
||||
context.appendAppVersion("18.48.39")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,25 +49,16 @@ object SpoofAppVersionPatch : BaseResourcePatch(
|
||||
SettingsPatch.updatePatchStatus(this)
|
||||
}
|
||||
|
||||
private fun ResourceContext.appendChild(entryArray: Array<Pair<String, String>>) {
|
||||
entryArray.map { (attributeName, attributeValue) ->
|
||||
this.xmlEditor["res/values/arrays.xml"].use { editor ->
|
||||
editor.file.apply {
|
||||
val resourcesNode = getElementsByTagName("resources").item(0) as Element
|
||||
|
||||
val newElement: Element = createElement("item")
|
||||
for (i in 0 until resourcesNode.childNodes.length) {
|
||||
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
|
||||
|
||||
if (node.getAttribute("name") == attributeName) {
|
||||
newElement.appendChild(createTextNode(attributeValue))
|
||||
val firstChild = node.firstChild
|
||||
|
||||
node.insertBefore(newElement, firstChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun ResourceContext.appendAppVersion(appVersion: String) {
|
||||
addEntryValues(
|
||||
ATTRIBUTE_NAME_ENTRIES,
|
||||
"@string/revanced_spoof_app_version_target_entry_" + appVersion.replace(".", "_"),
|
||||
prepend = false
|
||||
)
|
||||
addEntryValues(
|
||||
ATTRIBUTE_NAME_ENTRY_VALUE,
|
||||
appVersion,
|
||||
prepend = false
|
||||
)
|
||||
}
|
||||
}
|
@ -56,8 +56,16 @@ object DoubleTapLengthPatch : BaseResourcePatch(
|
||||
)
|
||||
|
||||
for (index in 0 until splits.count()) {
|
||||
context.addEntryValues(arrayPath, lengthElements[index], entryValueName)
|
||||
context.addEntryValues(arrayPath, lengthElements[index], entriesName)
|
||||
context.addEntryValues(
|
||||
entryValueName,
|
||||
lengthElements[index],
|
||||
path = arrayPath
|
||||
)
|
||||
context.addEntryValues(
|
||||
entriesName,
|
||||
lengthElements[index],
|
||||
path = arrayPath
|
||||
)
|
||||
}
|
||||
|
||||
SettingsPatch.updatePatchStatus(this)
|
||||
|
@ -30,8 +30,8 @@ import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.RegisterRangeInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc
|
||||
|
||||
@Suppress("unused")
|
||||
object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
@ -182,7 +182,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
PlayerControlsVisibilityModelFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val callIndex = indexOfFirstInstructionOrThrow(Opcode.INVOKE_DIRECT_RANGE)
|
||||
val callInstruction = getInstruction<Instruction3rc>(callIndex)
|
||||
val callInstruction = getInstruction<RegisterRangeInstruction>(callIndex)
|
||||
|
||||
val hasNextParameterRegister = callInstruction.startRegister + HAS_NEXT
|
||||
val hasPreviousParameterRegister = callInstruction.startRegister + HAS_PREVIOUS
|
||||
|
@ -50,23 +50,27 @@ object ResourceUtils {
|
||||
}
|
||||
|
||||
fun ResourceContext.addEntryValues(
|
||||
path: String,
|
||||
speedEntryValues: String,
|
||||
attributeName: String
|
||||
attributeName: String,
|
||||
attributeValue: String,
|
||||
path: String = "res/values/arrays.xml",
|
||||
prepend: Boolean = true,
|
||||
) {
|
||||
xmlEditor[path].use {
|
||||
with(it.file) {
|
||||
val resourcesNode = getElementsByTagName("resources").item(0) as Element
|
||||
|
||||
val newElement: Element = createElement("item")
|
||||
|
||||
for (i in 0 until resourcesNode.childNodes.length) {
|
||||
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
|
||||
|
||||
if (node.getAttribute("name") == attributeName) {
|
||||
newElement.appendChild(createTextNode(speedEntryValues))
|
||||
newElement.appendChild(createTextNode(attributeValue))
|
||||
|
||||
node.appendChild(newElement)
|
||||
if (prepend) {
|
||||
node.appendChild(newElement)
|
||||
} else {
|
||||
node.insertBefore(newElement, node.firstChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
|
||||
const val REGISTER_TEMPLATE_REPLACEMENT: String = "REGISTER_INDEX"
|
||||
|
||||
fun MethodFingerprint.deprecatedOrResultOrThrow() =
|
||||
if (javaClass.annotations[0].toString().contains("Deprecated")) result else resultOrThrow()
|
||||
fun MethodFingerprint.isDeprecated() =
|
||||
javaClass.annotations[0].toString().contains("Deprecated")
|
||||
|
||||
fun MethodFingerprint.resultOrThrow() = result ?: throw exception
|
||||
|
||||
|
Reference in New Issue
Block a user