From 6bffafb24a9f5c28cd75da3b36fc7d1a2a2a2e40 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:41:43 +0900 Subject: [PATCH] feat(YouTube/Spoof app version): add target version 18.33.40 - Restore old shorts action bar --- .../spoofappversion/SpoofAppVersionPatch.kt | 31 +++++++++++++++++++ .../youtube/settings/host/values/strings.xml | 1 + 2 files changed, 32 insertions(+) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt index eb091c5ec..d7cbaafac 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.misc.spoofappversion import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.patch.versionspoof.AbstractVersionSpoofPatch @@ -8,6 +9,7 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts import app.revanced.util.integrations.Constants.MISC_PATH import app.revanced.util.resources.ResourceUtils.copyXmlNode +import org.w3c.dom.Element @Patch( name = "Spoof app version", @@ -47,6 +49,10 @@ object SpoofAppVersionPatch : AbstractVersionSpoofPatch( */ contexts.copyXmlNode("youtube/spoofappversion/host", "values/arrays.xml", "resources") + if (SettingsPatch.upward1834) { + contexts.appendChild() + } + /** * Add settings */ @@ -60,4 +66,29 @@ object SpoofAppVersionPatch : AbstractVersionSpoofPatch( SettingsPatch.updatePatchStatus("Spoof app version") } + + private fun ResourceContext.appendChild(){ + arrayOf( + "revanced_spoof_app_version_target_entry" to "@string/revanced_spoof_app_version_target_entry_18_33_40", + "revanced_spoof_app_version_target_entry_value" to "18.33.40", + ).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) + } + } + } + } + } + } } \ No newline at end of file diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index f88ba3add..a641506ba 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -653,6 +653,7 @@ If later turned off, the old UI may remain until clear the app data" "18.01.38 - Remove 'Comments by members' banner" 18.05.40 - Restore old comment input box 18.17.43 - Restore old player flyout panel + 18.33.40 - Restore old shorts action bar Spoof app version target Type the spoof app version target Edit spoof app version