mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
feat(YouTube/Hide feed components): add Hide feed captions button
settings
This commit is contained in:
@ -10,6 +10,8 @@ import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.BreakingNewsFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.CaptionsButtonFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.CaptionsButtonSyntheticFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletFingerprint
|
||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletSyntheticFingerprint
|
||||
@ -28,10 +30,12 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.FEED_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CaptionToggleContainer
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -55,6 +59,8 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(
|
||||
BreakingNewsFingerprint,
|
||||
CaptionsButtonFingerprint,
|
||||
CaptionsButtonSyntheticFingerprint,
|
||||
ChannelListSubMenuFingerprint,
|
||||
ChannelListSubMenuTabletFingerprint,
|
||||
ChannelListSubMenuTabletSyntheticFingerprint,
|
||||
@ -101,6 +107,34 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide caption button
|
||||
|
||||
CaptionsButtonFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(CaptionToggleContainer)
|
||||
val insertIndex = getTargetIndexReversed(constIndex, Opcode.IF_EQZ)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $FEED_CLASS_DESCRIPTOR->hideCaptionsButton(Landroid/view/View;)Landroid/view/View;
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
CaptionsButtonSyntheticFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(CaptionToggleContainer)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $FEED_CLASS_DESCRIPTOR->hideCaptionsButtonContainer(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide subscriptions channel section for tablet
|
||||
|
||||
arrayOf(
|
||||
|
@ -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.CaptionToggleContainer
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object CaptionsButtonFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
literalSupplier = { CaptionToggleContainer }
|
||||
)
|
@ -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.CaptionToggleContainer
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object CaptionsButtonSyntheticFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Landroid/view/View;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.BRIDGE or AccessFlags.SYNTHETIC,
|
||||
parameters = listOf("Landroid/content/Context;"),
|
||||
literalSupplier = { CaptionToggleContainer }
|
||||
)
|
@ -32,6 +32,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var BarContainerHeight = -1L
|
||||
var BottomSheetFooterText = -1L
|
||||
var BottomUiContainerStub = -1L
|
||||
var CaptionToggleContainer = -1L
|
||||
var CastMediaRouteButton = -1L
|
||||
var ChannelListSubMenu = -1L
|
||||
var CompactLink = -1L
|
||||
@ -111,6 +112,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
BarContainerHeight = getId(DIMEN, "bar_container_height")
|
||||
BottomSheetFooterText = getId(ID, "bottom_sheet_footer_text")
|
||||
BottomUiContainerStub = getId(ID, "bottom_ui_container_stub")
|
||||
CaptionToggleContainer = getId(ID, "caption_toggle_container")
|
||||
CastMediaRouteButton = getId(LAYOUT, "castmediaroutebutton")
|
||||
ChannelListSubMenu = getId(LAYOUT, "channel_list_sub_menu")
|
||||
CompactLink = getId(LAYOUT, "compact_link")
|
||||
|
Reference in New Issue
Block a user