@@ -9,6 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
99import app.revanced.patcher.patch.PatchException
1010import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
1111import app.revanced.patcher.util.smali.ExternalLabel
12+ import app.revanced.patches.shared.fingerprints.StartVideoInformerFingerprint
1213import app.revanced.patches.shared.litho.LithoFilterPatch
1314import app.revanced.patches.youtube.player.components.fingerprints.CrowdfundingBoxFingerprint
1415import app.revanced.patches.youtube.player.components.fingerprints.EngagementPanelControllerFingerprint
@@ -20,6 +21,9 @@ import app.revanced.patches.youtube.player.components.fingerprints.InfoCardsInco
2021import app.revanced.patches.youtube.player.components.fingerprints.LayoutCircleFingerprint
2122import app.revanced.patches.youtube.player.components.fingerprints.LayoutIconFingerprint
2223import 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
2327import app.revanced.patches.youtube.player.components.fingerprints.QuickSeekOverlayFingerprint
2428import app.revanced.patches.youtube.player.components.fingerprints.SeekEduContainerFingerprint
2529import 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 ))
0 commit comments