mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
fix(YouTube - Hide load more button): Include patch with Hide layout components
, and hide button only in search feed (#2959)
This commit is contained in:
parent
9479a9584f
commit
b007e8e06a
9 changed files with 57 additions and 101 deletions
|
@ -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<OneRegisterInstruction>(moveRegisterIndex).registerA
|
||||
|
||||
val insertIndex = moveRegisterIndex + 1
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$viewRegister }, " +
|
||||
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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 }
|
||||
)
|
|
@ -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<OneRegisterInstruction>(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) {}
|
||||
}
|
|
@ -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 }
|
||||
)
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -83,6 +83,11 @@
|
|||
<string name="revanced_hide_search_result_recommendations_title">Hide \'People also watched\' recommendations</string>
|
||||
<string name="revanced_hide_search_result_recommendations_summary_on">Recommendations are hidden</string>
|
||||
<string name="revanced_hide_search_result_recommendations_summary_off">Recommendations are shown</string>
|
||||
<!-- 'Show more' should be translated with the same localized wording that YouTube displays.
|
||||
This button usually appears when searching for a YT creator. -->
|
||||
<string name="revanced_hide_show_more_button_title">Hide \'Show more\' button</string>
|
||||
<string name="revanced_hide_show_more_button_summary_on">Button is hidden</string>
|
||||
<string name="revanced_hide_show_more_button_summary_off">Button is shown</string>
|
||||
<string name="revanced_hide_timed_reactions_title">Hide timed reactions</string>
|
||||
<string name="revanced_hide_timed_reactions_summary_on">Timed reactions are hidden</string>
|
||||
<string name="revanced_hide_timed_reactions_summary_off">Timed reactions are shown</string>
|
||||
|
@ -507,13 +512,6 @@
|
|||
<string name="revanced_hide_info_cards_summary_on">Info cards are hidden</string>
|
||||
<string name="revanced_hide_info_cards_summary_off">Info cards are shown</string>
|
||||
</patch>
|
||||
<patch id="layout.hide.loadmorebutton.HideLoadMoreButtonResourcePatch">
|
||||
<!-- 'Load more' should be translated with the same localized wording that YouTube displays.
|
||||
This commonly appears when searching for a YT creator. -->
|
||||
<string name="revanced_hide_load_more_button_title">Hide \'Load More\' button</string>
|
||||
<string name="revanced_hide_load_more_button_summary_on">Button is hidden</string>
|
||||
<string name="revanced_hide_load_more_button_summary_off">Button is shown</string>
|
||||
</patch>
|
||||
<patch id="layout.hide.rollingnumber.DisableRollingNumberAnimationPatch">
|
||||
<string name="revanced_disable_rolling_number_animations_title">Disable rolling number animations</string>
|
||||
<string name="revanced_disable_rolling_number_animations_summary_on">Rolling numbers are not animated</string>
|
||||
|
|
Loading…
Reference in a new issue