Skip to content

Commit 703359f

Browse files
feat(YouTube): Support version 20.12.46 (#4779)
1 parent e2b9d65 commit 703359f

File tree

73 files changed

+283
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+283
-145
lines changed

patches/api/patches.api

+2
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,8 @@ public final class app/revanced/patches/youtube/misc/playservice/VersionCheckPat
14161416
public static final fun is_20_07_or_greater ()Z
14171417
public static final fun is_20_09_or_greater ()Z
14181418
public static final fun is_20_10_or_greater ()Z
1419+
public static final fun is_20_14_or_greater ()Z
1420+
public static final fun is_20_15_or_greater ()Z
14191421
}
14201422

14211423
public final class app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatchKt {

patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ val hideAdsPatch = bytecodePatch(
8484
"19.43.41",
8585
"19.47.53",
8686
"20.07.39",
87-
),
87+
"20.12.46",
88+
)
8889
)
8990

9091
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ val hideGetPremiumPatch = bytecodePatch(
3131
"19.43.41",
3232
"19.47.53",
3333
"20.07.39",
34-
),
34+
"20.12.46",
35+
)
3536
)
3637

3738
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ val videoAdsPatch = bytecodePatch(
2929
"19.43.41",
3030
"19.47.53",
3131
"20.07.39",
32-
),
32+
"20.12.46",
33+
)
3334
)
3435

3536
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ val copyVideoUrlPatch = bytecodePatch(
5959
"19.43.41",
6060
"19.47.53",
6161
"20.07.39",
62-
),
62+
"20.12.46",
63+
)
6364
)
6465

6566
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ val removeViewerDiscretionDialogPatch = bytecodePatch(
3030
"19.43.41",
3131
"19.47.53",
3232
"20.07.39",
33-
),
33+
"20.12.46",
34+
)
3435
)
3536

3637
val extensionMethodDescriptor =

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ val downloadsPatch = bytecodePatch(
7474
"19.43.41",
7575
"19.47.53",
7676
"20.07.39",
77-
),
77+
"20.12.46",
78+
)
7879
)
7980

8081
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt

+27-24
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
1010
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
1111
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
1212
import app.revanced.patches.youtube.misc.settings.settingsPatch
13+
import app.revanced.util.findFreeRegister
14+
import app.revanced.util.indexOfFirstInstructionOrThrow
15+
import com.android.tools.smali.dexlib2.Opcode
16+
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
1317
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
14-
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
1518
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
1619

20+
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/SeekbarTappingPatch;"
21+
1722
val enableSeekbarTappingPatch = bytecodePatch(
1823
description = "Adds an option to enable tap to seek on the seekbar of the video player.",
1924
) {
@@ -31,39 +36,37 @@ val enableSeekbarTappingPatch = bytecodePatch(
3136
)
3237

3338
// Find the required methods to tap the seekbar.
34-
val patternMatch = onTouchEventHandlerFingerprint.patternMatch!!
35-
36-
fun getReference(index: Int) = onTouchEventHandlerFingerprint.method.getInstruction<ReferenceInstruction>(index)
37-
.reference as MethodReference
39+
val seekbarTappingMethods = onTouchEventHandlerFingerprint.let {
40+
fun getMethodReference(index: Int) = it.method.getInstruction<ReferenceInstruction>(index)
41+
.reference as MethodReference
3842

39-
val seekbarTappingMethods = buildMap {
40-
put("N", getReference(patternMatch.startIndex))
41-
put("O", getReference(patternMatch.endIndex))
43+
listOf(
44+
getMethodReference(it.patternMatch!!.startIndex),
45+
getMethodReference(it.patternMatch!!.endIndex)
46+
)
4247
}
4348

44-
val insertIndex = seekbarTappingFingerprint.patternMatch!!.endIndex - 1
45-
4649
seekbarTappingFingerprint.method.apply {
47-
val thisInstanceRegister = getInstruction<Instruction35c>(insertIndex - 1).registerC
48-
49-
val freeRegister = 0
50-
val xAxisRegister = 2
50+
val pointIndex = indexOfNewPointInstruction(this)
51+
val invokeIndex = indexOfFirstInstructionOrThrow(pointIndex, Opcode.INVOKE_VIRTUAL)
52+
val insertIndex = invokeIndex + 1
5153

52-
val oMethod = seekbarTappingMethods["O"]!!
53-
val nMethod = seekbarTappingMethods["N"]!!
54+
val thisInstanceRegister = getInstruction<FiveRegisterInstruction>(invokeIndex).registerC
55+
val xAxisRegister = this.getInstruction<FiveRegisterInstruction>(pointIndex).registerD
56+
val freeRegister = findFreeRegister(insertIndex, thisInstanceRegister, xAxisRegister)
5457

55-
fun MethodReference.toInvokeInstructionString() =
56-
"invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $this"
58+
val oMethod = seekbarTappingMethods[0]
59+
val nMethod = seekbarTappingMethods[1]
5760

5861
addInstructionsWithLabels(
5962
insertIndex,
6063
"""
61-
invoke-static { }, Lapp/revanced/extension/youtube/patches/SeekbarTappingPatch;->seekbarTappingEnabled()Z
62-
move-result v$freeRegister
63-
if-eqz v$freeRegister, :disabled
64-
${oMethod.toInvokeInstructionString()}
65-
${nMethod.toInvokeInstructionString()}
66-
""",
64+
invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->seekbarTappingEnabled()Z
65+
move-result v$freeRegister
66+
if-eqz v$freeRegister, :disabled
67+
invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $oMethod
68+
invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $nMethod
69+
""",
6770
ExternalLabel("disabled", getInstruction(insertIndex)),
6871
)
6972
}

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/Fingerprints.kt

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package app.revanced.patches.youtube.interaction.seekbar
22

33
import app.revanced.patcher.fingerprint
4+
import app.revanced.util.containsLiteralInstruction
45
import app.revanced.util.getReference
56
import app.revanced.util.indexOfFirstInstruction
7+
import app.revanced.util.indexOfFirstInstructionReversed
68
import app.revanced.util.literal
79
import com.android.tools.smali.dexlib2.AccessFlags
810
import com.android.tools.smali.dexlib2.Opcode
11+
import com.android.tools.smali.dexlib2.iface.Method
12+
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
913
import com.android.tools.smali.dexlib2.iface.reference.StringReference
1014

1115
internal val swipingUpGestureParentFingerprint = fingerprint {
@@ -101,14 +105,17 @@ internal val seekbarTappingFingerprint = fingerprint {
101105
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
102106
returns("Z")
103107
parameters("L")
104-
opcodes(
105-
Opcode.IPUT_OBJECT,
106-
Opcode.INVOKE_VIRTUAL,
107-
// Insert seekbar tapping instructions here.
108-
Opcode.RETURN,
109-
Opcode.INVOKE_VIRTUAL,
110-
)
111-
literal { Integer.MAX_VALUE.toLong() }
108+
custom { method, _ ->
109+
method.name == "onTouchEvent"
110+
&& method.containsLiteralInstruction(Integer.MAX_VALUE.toLong())
111+
&& indexOfNewPointInstruction(method) >= 0
112+
}
113+
}
114+
115+
internal fun indexOfNewPointInstruction(method: Method) = method.indexOfFirstInstructionReversed {
116+
val reference = getReference<MethodReference>()
117+
reference?.definingClass == "Landroid/graphics/Point;"
118+
&& reference.name == "<init>"
112119
}
113120

114121
internal val slideToSeekFingerprint = fingerprint {

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarPatch.kt

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ val seekbarPatch = bytecodePatch(
2626
"19.43.41",
2727
"19.47.53",
2828
"20.07.39",
29+
"20.12.46",
2930
)
3031
)
3132
}

patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ val swipeControlsPatch = bytecodePatch(
8787
"19.43.41",
8888
"19.47.53",
8989
"20.07.39",
90-
),
90+
"20.12.46",
91+
)
9192
)
9293

9394
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ val autoCaptionsPatch = bytecodePatch(
2828
"19.43.41",
2929
"19.47.53",
3030
"20.07.39",
31-
),
31+
"20.12.46",
32+
)
3233
)
3334

3435
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ val customBrandingPatch = resourcePatch(
4949
"19.43.41",
5050
"19.47.53",
5151
"20.07.39",
52-
),
52+
"20.12.46",
53+
)
5354
)
5455

5556
val appName by stringOption(

patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ val changeHeaderPatch = resourcePatch(
4747
"19.43.41",
4848
"19.47.53",
4949
"20.07.39",
50+
"20.12.46",
5051
)
5152
)
5253

patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ val hideButtonsPatch = resourcePatch(
2828
"19.43.41",
2929
"19.47.53",
3030
"20.07.39",
31-
),
31+
"20.12.46",
32+
)
3233
)
3334

3435
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ val navigationButtonsPatch = bytecodePatch(
4646
"19.43.41",
4747
"19.47.53",
4848
"20.07.39",
49-
),
49+
"20.12.46",
50+
)
5051
)
5152

5253
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch(
6060
"19.43.41",
6161
"19.47.53",
6262
"20.07.39",
63-
),
63+
"20.12.46",
64+
)
6465
)
6566

6667
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ val changeFormFactorPatch = bytecodePatch(
3939
"19.43.41",
4040
"19.47.53",
4141
"20.07.39",
42-
),
42+
"20.12.46",
43+
)
4344
)
4445

4546
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ val hideEndscreenCardsPatch = bytecodePatch(
6565
"19.43.41",
6666
"19.47.53",
6767
"20.07.39",
68-
),
68+
"20.12.46",
69+
)
6970
)
7071

7172
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ val hideEndScreenSuggestedVideoPatch = bytecodePatch(
3737
"19.43.41",
3838
"19.47.53",
3939
"20.07.39",
40-
),
40+
"20.12.46",
41+
)
4142
)
4243

4344
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ val disableFullscreenAmbientModePatch = bytecodePatch(
3535
"19.43.41",
3636
"19.47.53",
3737
"20.07.39",
38-
),
38+
"20.12.46",
39+
)
3940
)
4041

4142
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/Fingerprints.kt

+18-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,22 @@ internal val hideShowMoreButtonFingerprint = fingerprint {
1616
}
1717

1818
/**
19-
* 20.07+
19+
* 20.12+
2020
*/
2121
internal val parseElementFromBufferFingerprint = fingerprint {
22+
parameters("L", "L", "[B", "L", "L")
23+
opcodes(
24+
Opcode.IGET_OBJECT,
25+
Opcode.INVOKE_INTERFACE,
26+
Opcode.MOVE_RESULT_OBJECT,
27+
)
28+
strings("Failed to parse Element") // String is a partial match.
29+
}
30+
31+
/**
32+
* 20.07+
33+
*/
34+
internal val parseElementFromBufferLegacy2007Fingerprint = fingerprint {
2235
parameters("L", "L", "[B", "L", "L")
2336
opcodes(
2437
Opcode.IGET_OBJECT,
@@ -29,7 +42,10 @@ internal val parseElementFromBufferFingerprint = fingerprint {
2942
strings("Failed to parse Element") // String is a partial match.
3043
}
3144

32-
internal val parseElementFromBufferLegacyFingerprint = fingerprint {
45+
/**
46+
* 19.01 - 20.06
47+
*/
48+
internal val parseElementFromBufferLegacy1901Fingerprint = fingerprint {
3349
parameters("L", "L", "[B", "L", "L")
3450
opcodes(
3551
Opcode.IGET_OBJECT,

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
2121
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
2222
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
2323
import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater
24+
import app.revanced.patches.youtube.misc.playservice.is_20_09_or_greater
2425
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
2526
import app.revanced.patches.youtube.misc.settings.settingsPatch
2627
import app.revanced.util.findFreeRegister
@@ -132,7 +133,8 @@ val hideLayoutComponentsPatch = bytecodePatch(
132133
"19.43.41",
133134
"19.47.53",
134135
"20.07.39",
135-
),
136+
"20.12.46",
137+
)
136138
)
137139

138140
execute {
@@ -247,8 +249,9 @@ val hideLayoutComponentsPatch = bytecodePatch(
247249

248250
// region Mix playlists
249251

250-
(if (is_20_07_or_greater) parseElementFromBufferFingerprint
251-
else parseElementFromBufferLegacyFingerprint).let {
252+
(if (is_20_09_or_greater) parseElementFromBufferFingerprint
253+
else if (is_20_07_or_greater) parseElementFromBufferLegacy2007Fingerprint
254+
else parseElementFromBufferLegacy1901Fingerprint).let {
252255
it.method.apply {
253256
val byteArrayParameter = "p3"
254257
val startIndex = it.patternMatch!!.startIndex

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ val hideInfoCardsPatch = bytecodePatch(
6363
"19.43.41",
6464
"19.47.53",
6565
"20.07.39",
66-
),
66+
"20.12.46",
67+
)
6768
)
6869

6970
execute {

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ val hidePlayerFlyoutMenuPatch = bytecodePatch(
3030
"19.43.41",
3131
"19.47.53",
3232
"20.07.39",
33-
),
33+
"20.12.46",
34+
)
3435
)
3536

3637
execute {

0 commit comments

Comments
 (0)