mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 00:24:34 +02:00
fix(YouTube/Hide feed components): Hide Latest videos button
setting does not support tablets (#89)
* fix(YouTube - Hide Latest Video button): Patch should handle `Tap to update` button * Update fingerprint * Add layout resources * Update patches * feat: instead of checking the opcode pattern, use the `injectLiteralInstructionViewCall` function --------- Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com>
This commit is contained in:
parent
ffcc9e5db8
commit
c932956808
@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.music.general.components.fingerprints.ChipCloudFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.ContentPillInFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.ContentPillFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.FloatingButtonFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.FloatingButtonParentFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.HistoryMenuItemFingerprint
|
||||
@ -57,7 +57,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(
|
||||
ChipCloudFingerprint,
|
||||
ContentPillInFingerprint,
|
||||
ContentPillFingerprint,
|
||||
FloatingButtonParentFingerprint,
|
||||
HistoryMenuItemFingerprint,
|
||||
HistoryMenuItemOfflineTabFingerprint,
|
||||
@ -208,7 +208,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// region patch for hide tap to update button
|
||||
|
||||
ContentPillInFingerprint.resultOrThrow().let {
|
||||
ContentPillFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructionsWithLabels(
|
||||
0,
|
||||
|
@ -2,7 +2,7 @@ package app.revanced.patches.music.general.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object ContentPillInFingerprint : MethodFingerprint(
|
||||
internal object ContentPillFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
strings = listOf("Content pill VE is null")
|
||||
)
|
@ -18,6 +18,7 @@ import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubM
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletSyntheticFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelTabBuilderFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelTabRendererFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ContentPillFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ElementParserFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ElementParserParentFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.EngagementPanelUpdateFingerprint
|
||||
@ -37,8 +38,13 @@ import app.revanced.patches.youtube.utils.integrations.Constants.FEED_PATH
|
||||
import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
|
||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.Bar
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CaptionToggleContainer
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ChannelListSubMenu
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ContentPill
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.HorizontalCardList
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.alsoResolve
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
@ -46,6 +52,7 @@ import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
|
||||
import app.revanced.util.injectLiteralInstructionViewCall
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -78,6 +85,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
ChannelListSubMenuTabletFingerprint,
|
||||
ChannelListSubMenuTabletSyntheticFingerprint,
|
||||
ChannelTabRendererFingerprint,
|
||||
ContentPillFingerprint,
|
||||
ElementParserParentFingerprint,
|
||||
EngagementPanelBuilderFingerprint,
|
||||
FilterBarHeightFingerprint,
|
||||
@ -106,23 +114,35 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// region patch for hide carousel shelf, subscriptions channel section, latest videos button
|
||||
|
||||
mapOf(
|
||||
BreakingNewsFingerprint to "hideBreakingNewsShelf", // carousel shelf, only used to tablet layout.
|
||||
ChannelListSubMenuFingerprint to "hideSubscriptionsChannelSection", // subscriptions channel section
|
||||
LatestVideosButtonFingerprint to "hideLatestVideosButton", // latest videos button
|
||||
).forEach { (fingerprint, methodName) ->
|
||||
fingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister =
|
||||
getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $FEED_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
listOf(
|
||||
// carousel shelf, only used to tablet layout.
|
||||
Triple(
|
||||
BreakingNewsFingerprint,
|
||||
"hideBreakingNewsShelf",
|
||||
HorizontalCardList
|
||||
),
|
||||
// subscriptions channel section.
|
||||
Triple(
|
||||
ChannelListSubMenuFingerprint,
|
||||
"hideSubscriptionsChannelSection",
|
||||
ChannelListSubMenu
|
||||
),
|
||||
// latest videos button
|
||||
Triple(
|
||||
ContentPillFingerprint,
|
||||
"hideLatestVideosButton",
|
||||
ContentPill
|
||||
),
|
||||
Triple(
|
||||
LatestVideosButtonFingerprint,
|
||||
"hideLatestVideosButton",
|
||||
Bar
|
||||
),
|
||||
).forEach { (fingerprint, methodName, literal) ->
|
||||
val smaliInstruction = """
|
||||
invoke-static {v$REGISTER_TEMPLATE_REPLACEMENT}, $FEED_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V
|
||||
"""
|
||||
fingerprint.injectLiteralInstructionViewCall(literal, smaliInstruction)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
@ -4,15 +4,8 @@ import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.HorizontalCardList
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object BreakingNewsFingerprint : LiteralValueFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
literalSupplier = { HorizontalCardList },
|
||||
)
|
@ -2,14 +2,7 @@ package app.revanced.patches.youtube.feed.components.fingerprints
|
||||
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ChannelListSubMenu
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object ChannelListSubMenuFingerprint : LiteralValueFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
literalSupplier = { ChannelListSubMenu },
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.feed.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ContentPill
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object ContentPillFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "Z"),
|
||||
literalSupplier = { ContentPill },
|
||||
)
|
@ -4,17 +4,10 @@ import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.Bar
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object LatestVideosButtonFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "Z"),
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
literalSupplier = { Bar },
|
||||
)
|
@ -42,6 +42,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var CompactLink = -1L
|
||||
var CompactListItem = -1L
|
||||
var ComponentLongClickListener = -1L
|
||||
var ContentPill = -1L
|
||||
var ControlsLayoutStub = -1L
|
||||
var DarkBackground = -1L
|
||||
var DarkSplashAnimation = -1L
|
||||
@ -150,6 +151,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
CompactLink = getId(LAYOUT, "compact_link")
|
||||
CompactListItem = getId(LAYOUT, "compact_list_item")
|
||||
ComponentLongClickListener = getId(ID, "component_long_click_listener")
|
||||
ContentPill = getId(LAYOUT, "content_pill")
|
||||
ControlsLayoutStub = getId(ID, "controls_layout_stub")
|
||||
DarkBackground = getId(ID, "dark_background")
|
||||
DarkSplashAnimation = getId(ID, "dark_splash_animation")
|
||||
|
Loading…
x
Reference in New Issue
Block a user