diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 5b81773834..d648e191bc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -6,6 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPatchOption import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.youtube.layout.hide.shorts.fingerprints.* @@ -76,6 +77,13 @@ object HideShortsComponentsPatch : BytecodePatch( ) { private const val FILTER_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/components/ShortsFilter;" + internal val hideShortsLongPressItem by booleanPatchOption( + key = "hideShortsAppShortcut", + default = false, + title = "hide Shorts app shortcut", + description = "Permanently hides the Shorts app shortcut (long pressing app icon)." + ) + override fun execute(context: BytecodeContext) { // region Hide the Shorts shelf. diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt index 67bd46b554..1fe15b0978 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt @@ -6,7 +6,10 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsPatch.hideShortsLongPressItem import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.findElementByAttributeValueOrThrow +import org.w3c.dom.Element @Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class]) object HideShortsComponentsResourcePatch : ResourcePatch() { @@ -16,6 +19,19 @@ object HideShortsComponentsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) + if (hideShortsLongPressItem == true) { + context.xmlEditor["res/xml/main_shortcuts.xml"].use { editor -> + val shortcuts = editor.file.getElementsByTagName("shortcuts").item(0) as Element + val shortsItem = + shortcuts.getElementsByTagName("shortcut").findElementByAttributeValueOrThrow( + "android:shortcutId", + "shorts-shortcut" + ) + + shortsItem.parentNode.removeChild(shortsItem) + } + } + SettingsPatch.PreferenceScreen.SHORTS.addPreferences( SwitchPreference("revanced_hide_shorts_home"), SwitchPreference("revanced_hide_shorts_subscriptions"),