Skip to content

Commit e03741f

Browse files
inotia00Francesco146
authored andcommitted
fix(YouTube - Overlay buttons): Always repeat button doesn't work when the video is minimized
1 parent 09c8cc5 commit e03741f

3 files changed

Lines changed: 2 additions & 93 deletions

File tree

src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsBytecodePatch.kt

Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,98 +4,21 @@ import app.revanced.patcher.data.BytecodeContext
44
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
55
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
66
import app.revanced.patcher.patch.BytecodePatch
7-
import app.revanced.patcher.patch.PatchException
87
import app.revanced.patcher.patch.annotation.Patch
98
import app.revanced.patcher.util.smali.ExternalLabel
10-
import app.revanced.patches.youtube.player.overlaybuttons.fingerprints.PlayerButtonConstructorFingerprint
119
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
1210
import app.revanced.patches.youtube.video.information.VideoInformationPatch
13-
import app.revanced.util.addFieldAndInstructions
14-
import app.revanced.util.getReference
15-
import app.revanced.util.getTargetIndexWithReferenceOrThrow
16-
import app.revanced.util.indexOfFirstInstruction
17-
import app.revanced.util.indexOfFirstInstructionOrThrow
18-
import app.revanced.util.resultOrThrow
19-
import com.android.tools.smali.dexlib2.Opcode
20-
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
21-
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
22-
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
23-
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
2411

2512
@Patch(dependencies = [VideoInformationPatch::class])
2613
object OverlayButtonsBytecodePatch : BytecodePatch(
27-
setOf(PlayerButtonConstructorFingerprint)
14+
emptySet()
2815
) {
2916
private const val INTEGRATIONS_ALWAYS_REPEAT_CLASS_DESCRIPTOR =
3017
"$UTILS_PATH/AlwaysRepeatPatch;"
3118

3219
override fun execute(context: BytecodeContext) {
3320

34-
// region patch for always repeat and pause
35-
36-
PlayerButtonConstructorFingerprint.resultOrThrow().mutableMethod.apply {
37-
val registerResolver = implementation!!.registerCount - parameters.size - 1 + 6 // p6
38-
39-
var invokerObjectIndex = indexOfFirstInstruction {
40-
opcode == Opcode.IPUT_OBJECT
41-
&& getReference<FieldReference>()?.definingClass == definingClass
42-
&& (this as TwoRegisterInstruction).registerA == registerResolver
43-
}
44-
if (invokerObjectIndex < 0) {
45-
val moveObjectIndex = indexOfFirstInstructionOrThrow {
46-
(this as? TwoRegisterInstruction)?.registerB == registerResolver
47-
}
48-
val moveObjectRegister =
49-
getInstruction<TwoRegisterInstruction>(moveObjectIndex).registerA
50-
invokerObjectIndex = indexOfFirstInstructionOrThrow(moveObjectIndex) {
51-
opcode == Opcode.IPUT_OBJECT
52-
&& getReference<FieldReference>()?.definingClass == definingClass
53-
&& (this as TwoRegisterInstruction).registerA == moveObjectRegister
54-
}
55-
}
56-
val invokerObjectReference =
57-
getInstruction<ReferenceInstruction>(invokerObjectIndex).reference
58-
59-
val onClickListenerReferenceIndex =
60-
getTargetIndexWithReferenceOrThrow("<init>(Ljava/lang/Object;I[B)V")
61-
val onClickListenerReference =
62-
getInstruction<ReferenceInstruction>(onClickListenerReferenceIndex).reference
63-
val onClickListenerClass =
64-
context.findClass((onClickListenerReference as MethodReference).definingClass)!!.mutableClass
65-
66-
var invokeInterfaceReference = ""
67-
onClickListenerClass.methods.find { method -> method.name == "onClick" }
68-
?.apply {
69-
val invokeInterfaceIndex =
70-
getTargetIndexWithReferenceOrThrow(invokerObjectReference.toString()) + 1
71-
if (getInstruction(invokeInterfaceIndex).opcode != Opcode.INVOKE_INTERFACE)
72-
throw PatchException("Opcode does not match")
73-
invokeInterfaceReference =
74-
getInstruction<ReferenceInstruction>(invokeInterfaceIndex).reference.toString()
75-
} ?: throw PatchException("Could not find onClick method")
76-
77-
val alwaysRepeatMutableClass =
78-
context.findClass(INTEGRATIONS_ALWAYS_REPEAT_CLASS_DESCRIPTOR)!!.mutableClass
79-
80-
val smaliInstructions =
81-
"""
82-
if-eqz v0, :ignore
83-
iget-object v1, v0, $invokerObjectReference
84-
if-eqz v1, :ignore
85-
invoke-interface {v1}, $invokeInterfaceReference
86-
:ignore
87-
return-void
88-
"""
89-
90-
alwaysRepeatMutableClass.addFieldAndInstructions(
91-
context,
92-
"pauseVideo",
93-
"pauseButtonClass",
94-
definingClass,
95-
smaliInstructions,
96-
true
97-
)
98-
}
21+
// region patch for always repeat
9922

10023
VideoInformationPatch.videoEndMethod.apply {
10124
addInstructionsWithLabels(

src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/fingerprints/PlayerButtonConstructorFingerprint.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ object SharedResourceIdPatch : ResourcePatch() {
9999
var Scrubbing = -1L
100100
var SeekEasyHorizontalTouchOffsetToStartScrubbing = -1L
101101
var SeekUndoEduOverlayStub = -1L
102-
var SingleLoopEduSnackBarText = -1L
103102
var SlidingDialogAnimation = -1L
104103
var SubtitleMenuSettingsFooterInfo = -1L
105104
var SuggestedAction = -1L
@@ -208,7 +207,6 @@ object SharedResourceIdPatch : ResourcePatch() {
208207
SeekEasyHorizontalTouchOffsetToStartScrubbing =
209208
getId(DIMEN, "seek_easy_horizontal_touch_offset_to_start_scrubbing")
210209
SeekUndoEduOverlayStub = getId(ID, "seek_undo_edu_overlay_stub")
211-
SingleLoopEduSnackBarText = getId(STRING, "single_loop_edu_snackbar_text")
212210
SlidingDialogAnimation = getId(STYLE, "SlidingDialogAnimation")
213211
SubtitleMenuSettingsFooterInfo = getId(STRING, "subtitle_menu_settings_footer_info")
214212
SuggestedAction = getId(LAYOUT, "suggested_action")

0 commit comments

Comments
 (0)