diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 5a7428d7..c15078dc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.layout.hide.general import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -17,16 +18,17 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen.Sorting import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.shared.misc.settings.preference.TextPreference +import app.revanced.patches.youtube.layout.hide.general.fingerprints.HideShowMoreButtonFingerprint import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint import app.revanced.patches.youtube.layout.hide.general.fingerprints.PlayerOverlayFingerprint import app.revanced.patches.youtube.layout.hide.general.fingerprints.ShowWatermarkFingerprint import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch -import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.resultOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Patch( @@ -36,8 +38,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction LithoFilterPatch::class, SettingsPatch::class, AddResourcesPatch::class, - NavigationBarHookPatch::class, - PlayerTypeHookPatch::class // Used by Keyword Content filter. + HideLayoutComponentsResourcePatch::class, + NavigationBarHookPatch::class // Used by Keyword Content filter. ], compatiblePackages = [ CompatiblePackage( @@ -66,7 +68,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction ) @Suppress("unused") object HideLayoutComponentsPatch : BytecodePatch( - setOf(ParseElementFromBufferFingerprint, PlayerOverlayFingerprint), + setOf(ParseElementFromBufferFingerprint, PlayerOverlayFingerprint, HideShowMoreButtonFingerprint), ) { private const val LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/components/LayoutComponentsFilter;" @@ -122,9 +124,7 @@ object HideLayoutComponentsPatch : BytecodePatch( SwitchPreference("revanced_hide_notify_me_button"), SwitchPreference("revanced_hide_search_result_recommendations"), SwitchPreference("revanced_hide_search_result_shelf_header"), - ) - - SettingsPatch.PreferenceScreen.FEED.addPreferences( + SwitchPreference("revanced_hide_show_more_button"), PreferenceScreen( key = "revanced_hide_keyword_content_screen", sorting = Sorting.UNSORTED, @@ -203,5 +203,24 @@ object HideLayoutComponentsPatch : BytecodePatch( } // endregion + + // region Show more button + + HideShowMoreButtonFingerprint.resultOrThrow().let { + it.mutableMethod.apply { + val moveRegisterIndex = it.scanResult.patternScanResult!!.endIndex + val viewRegister = + getInstruction(moveRegisterIndex).registerA + + val insertIndex = moveRegisterIndex + 1 + addInstruction( + insertIndex, + "invoke-static { v$viewRegister }, " + + "$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V" + ) + } + } + + // endregion } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt index 86d4734f..7b9dce7c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.hide.loadmorebutton +package app.revanced.patches.youtube.layout.hide.general import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch @@ -15,16 +15,10 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch AddResourcesPatch::class ] ) -internal object HideLoadMoreButtonResourcePatch : ResourcePatch() { +internal object HideLayoutComponentsResourcePatch : ResourcePatch() { internal var expandButtonDownId: Long = -1 override fun execute(context: ResourceContext) { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.FEED.addPreferences( - SwitchPreference("revanced_hide_load_more_button") - ) - expandButtonDownId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "expand_button_down" }.id diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/fingerprints/HideShowMoreButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/fingerprints/HideShowMoreButtonFingerprint.kt new file mode 100644 index 00000000..a9e66c3a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/fingerprints/HideShowMoreButtonFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.youtube.layout.hide.general.fingerprints + +import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.Opcode + +internal object HideShowMoreButtonFingerprint : LiteralValueFingerprint( + opcodes = listOf( + Opcode.CONST, + Opcode.CONST_4, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT + ), + literalSupplier = { HideLayoutComponentsResourcePatch.expandButtonDownId } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonPatch.kt index 91948d7f..0ad1000d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonPatch.kt @@ -1,65 +1,12 @@ package app.revanced.patches.youtube.layout.hide.loadmorebutton -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -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.patches.youtube.layout.hide.loadmorebutton.fingerprints.HideLoadMoreButtonFingerprint -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch -@Patch( - name = "Hide \'Load more\' button", - description = "Adds an option to hide the button under videos that loads similar videos.", - dependencies = [HideLoadMoreButtonResourcePatch::class], - compatiblePackages = [ - CompatiblePackage( - "com.google.android.youtube", - [ - "18.32.39", - "18.37.36", - "18.38.44", - "18.43.45", - "18.44.41", - "18.45.43", - "18.48.39", - "18.49.37", - "19.01.34", - "19.02.39", - "19.03.36", - "19.04.38", - "19.05.36", - "19.06.39", - "19.07.40", - "19.08.36", - "19.09.37" - ] - ) - ] -) -@Suppress("unused") +@Deprecated("This patch class has been merged into HideLayoutComponentsPatch.") object HideLoadMoreButtonPatch : BytecodePatch( - setOf(HideLoadMoreButtonFingerprint) + dependencies = setOf(HideLayoutComponentsPatch::class) ) { - private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/youtube/patches/HideLoadMoreButtonPatch;" - - override fun execute(context: BytecodeContext) { - HideLoadMoreButtonFingerprint.result?.let { - it.mutableMethod.apply { - val moveRegisterIndex = it.scanResult.patternScanResult!!.endIndex - val viewRegister = - getInstruction(moveRegisterIndex).registerA - - val insertIndex = moveRegisterIndex + 1 - addInstruction( - insertIndex, - "invoke-static { v$viewRegister }, " + - "$INTEGRATIONS_CLASS_DESCRIPTOR->hideLoadMoreButton(Landroid/view/View;)V" - ) - } - } ?: throw HideLoadMoreButtonFingerprint.exception - } -} + override fun execute(context: BytecodeContext) {} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/fingerprints/HideLoadMoreButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/fingerprints/HideLoadMoreButtonFingerprint.kt deleted file mode 100644 index 2433ae38..00000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/fingerprints/HideLoadMoreButtonFingerprint.kt +++ /dev/null @@ -1,15 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.loadmorebutton.fingerprints - -import app.revanced.patches.youtube.layout.hide.loadmorebutton.HideLoadMoreButtonResourcePatch -import app.revanced.util.patch.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.Opcode - -internal object HideLoadMoreButtonFingerprint : LiteralValueFingerprint( - opcodes = listOf( - Opcode.CONST, - Opcode.CONST_4, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT - ), - literalSupplier = { HideLoadMoreButtonResourcePatch.expandButtonDownId } -) \ No newline at end of file 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 e65eced6..d9db24b9 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 @@ -15,7 +15,6 @@ import app.revanced.patches.youtube.layout.hide.shorts.fingerprints.* import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch -import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @@ -28,8 +27,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction LithoFilterPatch::class, HideShortsComponentsResourcePatch::class, ResourceMappingPatch::class, - NavigationBarHookPatch::class, - PlayerTypeHookPatch::class + NavigationBarHookPatch::class ], compatiblePackages = [ CompatiblePackage( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index 2f624435..c7bd24ec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -23,7 +23,6 @@ import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.reques import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.request.callback.OnSucceededFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch -import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.resultOrThrow import com.android.tools.smali.dexlib2.AccessFlags @@ -40,8 +39,7 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethod IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class, - NavigationBarHookPatch::class, - PlayerTypeHookPatch::class + NavigationBarHookPatch::class ], compatiblePackages = [ CompatiblePackage( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt index 5b19cdc0..514ec929 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt @@ -10,6 +10,7 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.navigation.fingerprints.* +import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import app.revanced.util.resultOrThrow @@ -25,6 +26,7 @@ import com.android.tools.smali.dexlib2.util.MethodUtil dependencies = [ IntegrationsPatch::class, NavigationBarHookResourcePatch::class, + PlayerTypeHookPatch::class // Required to detect the search bar in all situations. ], ) @Suppress("unused") diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index 3e66569c..53571b78 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -83,6 +83,11 @@ Hide \'People also watched\' recommendations Recommendations are hidden Recommendations are shown + + Hide \'Show more\' button + Button is hidden + Button is shown Hide timed reactions Timed reactions are hidden Timed reactions are shown @@ -507,13 +512,6 @@ Info cards are hidden Info cards are shown - - - Hide \'Load More\' button - Button is hidden - Button is shown - Disable rolling number animations Rolling numbers are not animated