Skip to content

Commit e96317b

Browse files
committed
feat(YouTube - Player components): Hide player popup panels setting now hides the products panel
1 parent 2b4931a commit e96317b

7 files changed

Lines changed: 89 additions & 6 deletions

File tree

src/main/kotlin/app/revanced/patches/shared/captions/BaseAutoCaptionsPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
55
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
66
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
77
import app.revanced.patcher.patch.BytecodePatch
8-
import app.revanced.patches.shared.captions.fingerprints.StartVideoInformerFingerprint
98
import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint
9+
import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint
1010
import app.revanced.util.getWalkerMethod
1111
import app.revanced.util.indexOfFirstInstruction
1212
import app.revanced.util.resultOrThrow

src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/StartVideoInformerFingerprint.kt renamed to src/main/kotlin/app/revanced/patches/shared/fingerprints/StartVideoInformerFingerprint.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.shared.captions.fingerprints
1+
package app.revanced.patches.shared.fingerprints
22

33
import app.revanced.patcher.extensions.or
44
import app.revanced.patcher.fingerprint.MethodFingerprint

src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
99
import app.revanced.patcher.patch.PatchException
1010
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
1111
import app.revanced.patcher.util.smali.ExternalLabel
12+
import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint
1213
import app.revanced.patches.shared.litho.LithoFilterPatch
1314
import app.revanced.patches.youtube.player.components.fingerprints.CrowdfundingBoxFingerprint
1415
import app.revanced.patches.youtube.player.components.fingerprints.EngagementPanelControllerFingerprint
@@ -20,6 +21,9 @@ import app.revanced.patches.youtube.player.components.fingerprints.InfoCardsInco
2021
import app.revanced.patches.youtube.player.components.fingerprints.LayoutCircleFingerprint
2122
import app.revanced.patches.youtube.player.components.fingerprints.LayoutIconFingerprint
2223
import app.revanced.patches.youtube.player.components.fingerprints.LayoutVideoFingerprint
24+
import app.revanced.patches.youtube.player.components.fingerprints.LithoComponentOnClickListenerFingerprint
25+
import app.revanced.patches.youtube.player.components.fingerprints.NoticeOnClickListenerFingerprint
26+
import app.revanced.patches.youtube.player.components.fingerprints.OfflineActionsOnClickListenerFingerprint
2327
import app.revanced.patches.youtube.player.components.fingerprints.QuickSeekOverlayFingerprint
2428
import app.revanced.patches.youtube.player.components.fingerprints.SeekEduContainerFingerprint
2529
import app.revanced.patches.youtube.player.components.fingerprints.SuggestedActionsFingerprint
@@ -67,7 +71,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
6771
SettingsPatch::class,
6872
SharedResourceIdPatch::class,
6973
SpeedOverlayPatch::class,
70-
SuggestedVideoEndScreenPatch::class
74+
SuggestedVideoEndScreenPatch::class,
7175
),
7276
compatiblePackages = COMPATIBLE_PACKAGE,
7377
fingerprints = setOf(
@@ -78,8 +82,12 @@ object PlayerComponentsPatch : BaseBytecodePatch(
7882
LayoutCircleFingerprint,
7983
LayoutIconFingerprint,
8084
LayoutVideoFingerprint,
85+
LithoComponentOnClickListenerFingerprint,
86+
NoticeOnClickListenerFingerprint,
87+
OfflineActionsOnClickListenerFingerprint,
8188
QuickSeekOverlayFingerprint,
8289
SeekEduContainerFingerprint,
90+
StartVideoInformerFingerprint,
8391
SuggestedActionsFingerprint,
8492
TouchAreaOnClickListenerFingerprint,
8593
WatermarkParentFingerprint,
@@ -114,15 +122,45 @@ object PlayerComponentsPatch : BaseBytecodePatch(
114122

115123
// region patch for disable auto player popup panels
116124

125+
fun MutableMethod.hookInitVideoPanel(initVideoPanel: Int) =
126+
addInstructions(
127+
0, """
128+
const/4 v0, $initVideoPanel
129+
invoke-static {v0}, $PLAYER_CLASS_DESCRIPTOR->setInitVideoPanel(Z)V
130+
"""
131+
)
132+
133+
arrayOf(
134+
LithoComponentOnClickListenerFingerprint,
135+
NoticeOnClickListenerFingerprint,
136+
OfflineActionsOnClickListenerFingerprint,
137+
StartVideoInformerFingerprint,
138+
).forEach { fingerprint ->
139+
fingerprint.resultOrThrow().mutableMethod.apply {
140+
if (fingerprint == StartVideoInformerFingerprint) {
141+
hookInitVideoPanel(1)
142+
} else {
143+
val syntheticIndex = getTargetIndexOrThrow(Opcode.NEW_INSTANCE)
144+
val syntheticReference =
145+
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
146+
val syntheticClass =
147+
context.findClass(syntheticReference)!!.mutableClass
148+
149+
syntheticClass.methods.find { method -> method.name == "onClick" }
150+
?.hookInitVideoPanel(0)
151+
?: throw PatchException("Could not find onClick method in $syntheticReference")
152+
}
153+
}
154+
}
155+
117156
EngagementPanelControllerFingerprint.resultOrThrow().let {
118157
it.mutableMethod.apply {
119158
addInstructionsWithLabels(
120159
0, """
121-
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->disableAutoPlayerPopupPanels()Z
160+
move/from16 v0, p4
161+
invoke-static {v0}, $PLAYER_CLASS_DESCRIPTOR->disableAutoPlayerPopupPanels(Z)Z
122162
move-result v0
123163
if-eqz v0, :shown
124-
# The type of the fourth parameter is boolean.
125-
if-eqz p4, :shown
126164
const/4 v0, 0x0
127165
return-object v0
128166
""", ExternalLabel("shown", getInstruction(0))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package app.revanced.patches.youtube.player.components.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ComponentLongClickListener
5+
import app.revanced.util.fingerprint.LiteralValueFingerprint
6+
import com.android.tools.smali.dexlib2.AccessFlags
7+
8+
@Suppress("SpellCheckingInspection")
9+
internal object LithoComponentOnClickListenerFingerprint : LiteralValueFingerprint(
10+
returnType = "V",
11+
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC,
12+
parameters = listOf("L"),
13+
literalSupplier = { ComponentLongClickListener }
14+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package app.revanced.patches.youtube.player.components.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.Notice
5+
import app.revanced.util.fingerprint.LiteralValueFingerprint
6+
import com.android.tools.smali.dexlib2.AccessFlags
7+
8+
internal object NoticeOnClickListenerFingerprint : LiteralValueFingerprint(
9+
returnType = "V",
10+
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
11+
literalSupplier = { Notice }
12+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package app.revanced.patches.youtube.player.components.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.OfflineActionsVideoDeletedUndoSnackbarText
5+
import app.revanced.util.fingerprint.LiteralValueFingerprint
6+
import com.android.tools.smali.dexlib2.AccessFlags
7+
8+
internal object OfflineActionsOnClickListenerFingerprint : LiteralValueFingerprint(
9+
returnType = "V",
10+
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
11+
parameters = listOf("Ljava/lang/String;"),
12+
literalSupplier = { OfflineActionsVideoDeletedUndoSnackbarText }
13+
)

src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ object SharedResourceIdPatch : ResourcePatch() {
3838
var ChannelListSubMenu = -1L
3939
var CompactLink = -1L
4040
var CompactListItem = -1L
41+
var ComponentLongClickListener = -1L
4142
var ControlsLayoutStub = -1L
4243
var DarkBackground = -1L
4344
var DarkSplashAnimation = -1L
@@ -71,7 +72,9 @@ object SharedResourceIdPatch : ResourcePatch() {
7172
var ModernMiniPlayerForwardButton = -1L
7273
var ModernMiniPlayerRewindButton = -1L
7374
var MusicAppDeeplinkButtonView = -1L
75+
var Notice = -1L
7476
var NotificationBigPictureIconWidth = -1L
77+
var OfflineActionsVideoDeletedUndoSnackbarText = -1L
7578
var PlayerCollapseButton = -1L
7679
var PlayerVideoTitleView = -1L
7780
var PosterArtWidthDefault = -1L
@@ -138,6 +141,7 @@ object SharedResourceIdPatch : ResourcePatch() {
138141
ChannelListSubMenu = getId(LAYOUT, "channel_list_sub_menu")
139142
CompactLink = getId(LAYOUT, "compact_link")
140143
CompactListItem = getId(LAYOUT, "compact_list_item")
144+
ComponentLongClickListener = getId(ID, "component_long_click_listener")
141145
ControlsLayoutStub = getId(ID, "controls_layout_stub")
142146
DarkBackground = getId(ID, "dark_background")
143147
DarkSplashAnimation = getId(ID, "dark_splash_animation")
@@ -173,7 +177,9 @@ object SharedResourceIdPatch : ResourcePatch() {
173177
ModernMiniPlayerForwardButton = getId(ID, "modern_miniplayer_forward_button")
174178
ModernMiniPlayerRewindButton = getId(ID, "modern_miniplayer_rewind_button")
175179
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
180+
Notice = getId(ID, "notice")
176181
NotificationBigPictureIconWidth = getId(DIMEN, "notification_big_picture_icon_width")
182+
OfflineActionsVideoDeletedUndoSnackbarText = getId(STRING, "offline_actions_video_deleted_undo_snackbar_text")
177183
PlayerCollapseButton = getId(ID, "player_collapse_button")
178184
PlayerVideoTitleView = getId(ID, "player_video_title_view")
179185
PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default")

0 commit comments

Comments
 (0)