Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(YouTube - Hide load more button): Include patch with Hide layout components, and hide button only in search feed #2959

Merged
6 changes: 6 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,12 @@ public final class app/revanced/patches/youtube/layout/hide/shorts/HideShortsCom
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
}

public final class app/revanced/patches/youtube/layout/hide/showmorebutton/HideShowMoreButtonPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/showmorebutton/HideShowMoreButtonPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import app.revanced.patches.shared.misc.settings.preference.TextPreference
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.layout.hide.showmorebutton.HideShowMoreButtonPatch
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
Expand All @@ -36,8 +36,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.
HideShowMoreButtonPatch::class,
NavigationBarHookPatch::class // Used by Keyword Content filter.
],
compatiblePackages = [
CompatiblePackage(
Expand Down
Original file line number Diff line number Diff line change
@@ -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.showmorebutton.HideShowMoreButtonPatch

@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 renamed to HideShowMoreButtonPatch.")
object HideLoadMoreButtonPatch : BytecodePatch(
setOf(HideLoadMoreButtonFingerprint)
dependencies = setOf(HideShowMoreButtonPatch::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) {}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package app.revanced.patches.youtube.layout.hide.showmorebutton

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.showmorebutton.fingerprints.HideShowMoreButtonFingerprint
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction

@Patch(
description = "Adds an option to hide the button under videos that loads similar videos.",
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
dependencies = [
HideShowMoreButtonResourcePatch::class,
NavigationBarHookPatch::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")
object HideShowMoreButtonPatch : BytecodePatch(
setOf(HideShowMoreButtonFingerprint)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/HideShowMoreButtonPatch;"

override fun execute(context: BytecodeContext) {
HideShowMoreButtonFingerprint.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->hideShowMoreButton(Landroid/view/View;)V"
)
}
} ?: throw HideShowMoreButtonFingerprint.exception
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.hide.loadmorebutton
package app.revanced.patches.youtube.layout.hide.showmorebutton

import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
Expand All @@ -15,14 +15,14 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
AddResourcesPatch::class
]
)
internal object HideLoadMoreButtonResourcePatch : ResourcePatch() {
internal object HideShowMoreButtonResourcePatch : ResourcePatch() {
internal var expandButtonDownId: Long = -1

override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)

SettingsPatch.PreferenceScreen.FEED.addPreferences(
SwitchPreference("revanced_hide_load_more_button")
SwitchPreference("revanced_hide_show_more_button")
)

expandButtonDownId = ResourceMappingPatch.resourceMappings.single {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.revanced.patches.youtube.layout.hide.showmorebutton.fingerprints

import app.revanced.patches.youtube.layout.hide.showmorebutton.HideShowMoreButtonResourcePatch
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 = { HideShowMoreButtonResourcePatch.expandButtonDownId }
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,12 @@
<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 id="layout.hide.showmorebutton.HideShowMoreButtonResourcePatch">
<!-- '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>
</patch>
<patch id="layout.hide.rollingnumber.DisableRollingNumberAnimationPatch">
<string name="revanced_disable_rolling_number_animations_title">Disable rolling number animations</string>
Expand Down
Loading