From 703359f0c16b613c204cf16cf42227b628f664fa Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 16 Apr 2025 10:24:35 +0200 Subject: [PATCH] feat(YouTube): Support version `20.12.46` (#4779) --- patches/api/patches.api | 2 + .../youtube/ad/general/HideAdsPatch.kt | 3 +- .../ad/getpremium/HideGetPremiumPatch.kt | 3 +- .../patches/youtube/ad/video/VideoAdsPatch.kt | 3 +- .../copyvideourl/CopyVideoUrlPatch.kt | 3 +- .../RemoveViewerDiscretionDialogPatch.kt | 3 +- .../interaction/downloads/DownloadsPatch.kt | 3 +- .../seekbar/EnableSeekbarTappingPatch.kt | 51 ++++++++++--------- .../interaction/seekbar/Fingerprints.kt | 23 ++++++--- .../interaction/seekbar/SeekbarPatch.kt | 1 + .../swipecontrols/SwipeControlsPatch.kt | 3 +- .../layout/autocaptions/AutoCaptionsPatch.kt | 3 +- .../layout/branding/CustomBrandingPatch.kt | 3 +- .../branding/header/ChangeHeaderPatch.kt | 1 + .../layout/buttons/action/HideButtonsPatch.kt | 3 +- .../navigation/NavigationButtonsPatch.kt | 3 +- .../overlay/HidePlayerOverlayButtonsPatch.kt | 3 +- .../formfactor/ChangeFormFactorPatch.kt | 3 +- .../endscreencards/HideEndscreenCardsPatch.kt | 3 +- .../HideEndScreenSuggestedVideoPatch.kt | 3 +- .../DisableFullscreenAmbientModePatch.kt | 3 +- .../layout/hide/general/Fingerprints.kt | 20 +++++++- .../hide/general/HideLayoutComponentsPatch.kt | 9 ++-- .../hide/infocards/HideInfoCardsPatch.kt | 3 +- .../HidePlayerFlyoutMenuPatch.kt | 3 +- .../DisableRollingNumberAnimationPatch.kt | 3 +- .../hide/shorts/HideShortsComponentsPatch.kt | 3 +- .../youtube/layout/hide/time/Fingerprints.kt | 14 ++--- .../layout/hide/time/HideTimestampPatch.kt | 3 +- .../layout/miniplayer/MiniplayerPatch.kt | 11 +++- .../panels/popup/PlayerPopupPanelsPatch.kt | 3 +- .../PlayerControlsBackgroundPatch.kt | 3 +- .../player/fullscreen/ExitFullscreenPatch.kt | 1 + .../fullscreen/OpenVideosFullscreenPatch.kt | 1 + .../CustomPlayerOverlayOpacityPatch.kt | 3 +- .../returnyoutubedislike/Fingerprints.kt | 10 ++++ .../ReturnYouTubeDislikePatch.kt | 12 ++++- .../layout/searchbar/WideSearchbarPatch.kt | 3 +- .../shortsautoplay/ShortsAutoplayPatch.kt | 3 +- .../OpenShortsInRegularPlayerPatch.kt | 3 +- .../layout/sponsorblock/Fingerprints.kt | 6 --- .../layout/sponsorblock/SponsorBlockPatch.kt | 3 +- .../spoofappversion/SpoofAppVersionPatch.kt | 3 +- .../layout/startpage/ChangeStartPagePatch.kt | 3 +- .../DisableResumingShortsOnStartupPatch.kt | 3 +- .../youtube/layout/theme/Fingerprints.kt | 7 --- .../youtube/layout/theme/ThemePatch.kt | 3 +- .../thumbnails/AlternativeThumbnailsPatch.kt | 3 +- .../BypassImageRegionRestrictionsPatch.kt | 3 +- .../misc/announcements/AnnouncementsPatch.kt | 3 +- .../misc/autorepeat/AutoRepeatPatch.kt | 3 +- .../BackgroundPlaybackPatch.kt | 3 +- .../misc/debugging/EnableDebuggingPatch.kt | 3 +- .../spoof/SpoofDeviceDimensionsPatch.kt | 3 +- ...ckWatchHistoryDomainNameResolutionPatch.kt | 3 +- .../fix/backtoexitgesture/Fingerprints.kt | 7 +-- .../youtube/misc/gms/GmsCoreSupportPatch.kt | 3 +- .../misc/links/BypassURLRedirectsPatch.kt | 3 +- .../misc/links/OpenLinksExternallyPatch.kt | 3 +- .../youtube/misc/navigation/Fingerprints.kt | 6 +-- .../misc/playservice/VersionCheckPatch.kt | 6 +++ .../RemoveTrackingQueryParameterPatch.kt | 3 +- .../misc/spoof/SpoofVideoStreamsPatch.kt | 7 ++- .../misc/zoomhaptics/ZoomHapticsPatch.kt | 3 +- .../patches/youtube/shared/Fingerprints.kt | 10 +--- .../video/audio/ForceOriginalAudioPatch.kt | 3 +- .../youtube/video/hdr/DisableHdrPatch.kt | 3 +- .../youtube/video/information/Fingerprints.kt | 7 --- .../video/playerresponse/Fingerprints.kt | 28 +++++++++- .../PlayerResponseMethodHookPatch.kt | 6 ++- .../video/quality/VideoQualityPatch.kt | 1 + .../youtube/video/speed/PlaybackSpeedPatch.kt | 1 + .../kotlin/app/revanced/util/BytecodeUtils.kt | 39 +++++++++++--- 73 files changed, 283 insertions(+), 145 deletions(-) diff --git a/patches/api/patches.api b/patches/api/patches.api index 711eccede..414342e4e 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1416,6 +1416,8 @@ public final class app/revanced/patches/youtube/misc/playservice/VersionCheckPat public static final fun is_20_07_or_greater ()Z public static final fun is_20_09_or_greater ()Z public static final fun is_20_10_or_greater ()Z + public static final fun is_20_14_or_greater ()Z + public static final fun is_20_15_or_greater ()Z } public final class app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatchKt { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt index 5e0ca3b6b..dc66e4bfe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt @@ -84,7 +84,8 @@ val hideAdsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt index b98bebdc6..a3a00fb85 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt @@ -31,7 +31,8 @@ val hideGetPremiumPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt index 285ac733c..d1e9b9c26 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt @@ -29,7 +29,8 @@ val videoAdsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt index 13f1a3128..209886017 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlPatch.kt @@ -59,7 +59,8 @@ val copyVideoUrlPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index 28cae5018..79d373dc4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -30,7 +30,8 @@ val removeViewerDiscretionDialogPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) val extensionMethodDescriptor = diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt index ea7951222..202972f89 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt @@ -74,7 +74,8 @@ val downloadsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index fadf2357f..162b69090 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -10,10 +10,15 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch +import app.revanced.util.findFreeRegister +import app.revanced.util.indexOfFirstInstructionOrThrow +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c import com.android.tools.smali.dexlib2.iface.reference.MethodReference +private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/SeekbarTappingPatch;" + val enableSeekbarTappingPatch = bytecodePatch( description = "Adds an option to enable tap to seek on the seekbar of the video player.", ) { @@ -31,39 +36,37 @@ val enableSeekbarTappingPatch = bytecodePatch( ) // Find the required methods to tap the seekbar. - val patternMatch = onTouchEventHandlerFingerprint.patternMatch!! + val seekbarTappingMethods = onTouchEventHandlerFingerprint.let { + fun getMethodReference(index: Int) = it.method.getInstruction(index) + .reference as MethodReference - fun getReference(index: Int) = onTouchEventHandlerFingerprint.method.getInstruction(index) - .reference as MethodReference - - val seekbarTappingMethods = buildMap { - put("N", getReference(patternMatch.startIndex)) - put("O", getReference(patternMatch.endIndex)) + listOf( + getMethodReference(it.patternMatch!!.startIndex), + getMethodReference(it.patternMatch!!.endIndex) + ) } - val insertIndex = seekbarTappingFingerprint.patternMatch!!.endIndex - 1 - seekbarTappingFingerprint.method.apply { - val thisInstanceRegister = getInstruction(insertIndex - 1).registerC + val pointIndex = indexOfNewPointInstruction(this) + val invokeIndex = indexOfFirstInstructionOrThrow(pointIndex, Opcode.INVOKE_VIRTUAL) + val insertIndex = invokeIndex + 1 - val freeRegister = 0 - val xAxisRegister = 2 + val thisInstanceRegister = getInstruction(invokeIndex).registerC + val xAxisRegister = this.getInstruction(pointIndex).registerD + val freeRegister = findFreeRegister(insertIndex, thisInstanceRegister, xAxisRegister) - val oMethod = seekbarTappingMethods["O"]!! - val nMethod = seekbarTappingMethods["N"]!! - - fun MethodReference.toInvokeInstructionString() = - "invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $this" + val oMethod = seekbarTappingMethods[0] + val nMethod = seekbarTappingMethods[1] addInstructionsWithLabels( insertIndex, """ - invoke-static { }, Lapp/revanced/extension/youtube/patches/SeekbarTappingPatch;->seekbarTappingEnabled()Z - move-result v$freeRegister - if-eqz v$freeRegister, :disabled - ${oMethod.toInvokeInstructionString()} - ${nMethod.toInvokeInstructionString()} - """, + invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->seekbarTappingEnabled()Z + move-result v$freeRegister + if-eqz v$freeRegister, :disabled + invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $oMethod + invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $nMethod + """, ExternalLabel("disabled", getInstruction(insertIndex)), ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/Fingerprints.kt index 968ba89db..37ad6f750 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/Fingerprints.kt @@ -1,11 +1,15 @@ package app.revanced.patches.youtube.interaction.seekbar import app.revanced.patcher.fingerprint +import app.revanced.util.containsLiteralInstruction import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction +import app.revanced.util.indexOfFirstInstructionReversed import app.revanced.util.literal import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.Method +import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.StringReference internal val swipingUpGestureParentFingerprint = fingerprint { @@ -101,14 +105,17 @@ internal val seekbarTappingFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returns("Z") parameters("L") - opcodes( - Opcode.IPUT_OBJECT, - Opcode.INVOKE_VIRTUAL, - // Insert seekbar tapping instructions here. - Opcode.RETURN, - Opcode.INVOKE_VIRTUAL, - ) - literal { Integer.MAX_VALUE.toLong() } + custom { method, _ -> + method.name == "onTouchEvent" + && method.containsLiteralInstruction(Integer.MAX_VALUE.toLong()) + && indexOfNewPointInstruction(method) >= 0 + } +} + +internal fun indexOfNewPointInstruction(method: Method) = method.indexOfFirstInstructionReversed { + val reference = getReference() + reference?.definingClass == "Landroid/graphics/Point;" + && reference.name == "" } internal val slideToSeekFingerprint = fingerprint { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarPatch.kt index 7c053f5e4..c1456522f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarPatch.kt @@ -26,6 +26,7 @@ val seekbarPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", + "20.12.46", ) ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt index d20ebf9a7..e987ec4ce 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt @@ -87,7 +87,8 @@ val swipeControlsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index 4af370bc5..ce42ba21e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -28,7 +28,8 @@ val autoCaptionsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt index 79a1f3c09..cfb87c9f8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/CustomBrandingPatch.kt @@ -49,7 +49,8 @@ val customBrandingPatch = resourcePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) val appName by stringOption( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt index 1ff78cbe3..240c001d6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/ChangeHeaderPatch.kt @@ -47,6 +47,7 @@ val changeHeaderPatch = resourcePatch( "19.43.41", "19.47.53", "20.07.39", + "20.12.46", ) ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt index f6a8a0ff6..d88b1a816 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt @@ -28,7 +28,8 @@ val hideButtonsPatch = resourcePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index 3feee5b30..577f6cac0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -46,7 +46,8 @@ val navigationButtonsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt index 7ab7431b8..504fad256 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt @@ -60,7 +60,8 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt index 4c431fa52..97259dcbe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt @@ -39,7 +39,8 @@ val changeFormFactorPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt index 876238ee3..ce452111d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt @@ -65,7 +65,8 @@ val hideEndscreenCardsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt index 5ebcc637b..221487c9c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt @@ -37,7 +37,8 @@ val hideEndScreenSuggestedVideoPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index d7115ac81..664c966e5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -35,7 +35,8 @@ val disableFullscreenAmbientModePatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/Fingerprints.kt index 5216ea89a..3b7ec91fa 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/Fingerprints.kt @@ -16,9 +16,22 @@ internal val hideShowMoreButtonFingerprint = fingerprint { } /** - * 20.07+ + * 20.12+ */ internal val parseElementFromBufferFingerprint = fingerprint { + parameters("L", "L", "[B", "L", "L") + opcodes( + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + ) + strings("Failed to parse Element") // String is a partial match. +} + +/** + * 20.07+ + */ +internal val parseElementFromBufferLegacy2007Fingerprint = fingerprint { parameters("L", "L", "[B", "L", "L") opcodes( Opcode.IGET_OBJECT, @@ -29,7 +42,10 @@ internal val parseElementFromBufferFingerprint = fingerprint { strings("Failed to parse Element") // String is a partial match. } -internal val parseElementFromBufferLegacyFingerprint = fingerprint { +/** + * 19.01 - 20.06 + */ +internal val parseElementFromBufferLegacy1901Fingerprint = fingerprint { parameters("L", "L", "[B", "L", "L") opcodes( Opcode.IGET_OBJECT, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index d66202255..4e63a058e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -21,6 +21,7 @@ import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater +import app.revanced.patches.youtube.misc.playservice.is_20_09_or_greater import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.util.findFreeRegister @@ -132,7 +133,8 @@ val hideLayoutComponentsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { @@ -247,8 +249,9 @@ val hideLayoutComponentsPatch = bytecodePatch( // region Mix playlists - (if (is_20_07_or_greater) parseElementFromBufferFingerprint - else parseElementFromBufferLegacyFingerprint).let { + (if (is_20_09_or_greater) parseElementFromBufferFingerprint + else if (is_20_07_or_greater) parseElementFromBufferLegacy2007Fingerprint + else parseElementFromBufferLegacy1901Fingerprint).let { it.method.apply { val byteArrayParameter = "p3" val startIndex = it.patternMatch!!.startIndex diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt index 883fa1f16..9c24618c9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt @@ -63,7 +63,8 @@ val hideInfoCardsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt index cf104622e..b9555c8fe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt @@ -30,7 +30,8 @@ val hidePlayerFlyoutMenuPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index cf2b23464..dbfd90f61 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -35,7 +35,8 @@ val disableRollingNumberAnimationPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 025f9a1d7..37fc633d5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -178,7 +178,8 @@ val hideShortsComponentsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) hideShortsAppShortcutOption() diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/Fingerprints.kt index d109c6455..1f1876dc3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/Fingerprints.kt @@ -1,24 +1,16 @@ package app.revanced.patches.youtube.layout.hide.time +import app.revanced.patcher.fingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -import app.revanced.patcher.fingerprint -internal val timeCounterFingerprint = fingerprint( - fuzzyPatternScanThreshold = 1, -) { - returns("V") +internal val timeCounterFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("V") parameters() opcodes( Opcode.SUB_LONG_2ADDR, Opcode.IGET_WIDE, - Opcode.SUB_LONG_2ADDR, - Opcode.IGET_OBJECT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IGET_WIDE, - Opcode.IGET_WIDE, Opcode.SUB_LONG_2ADDR ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index e6d3f8768..fb84759c6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -27,7 +27,8 @@ val hideTimestampPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt index 98640db4e..d21c3952e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt @@ -30,6 +30,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstructio import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.FieldReference +import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.TypeReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter @@ -172,7 +173,8 @@ val miniplayerPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { @@ -346,7 +348,12 @@ val miniplayerPatch = bytecodePatch( // endregion // region Legacy tablet miniplayer hooks. - val appNameStringIndex = miniplayerOverrideFingerprint.stringMatches!!.first().index + 2 + val appNameStringIndex = miniplayerOverrideFingerprint.let { + it.method.indexOfFirstInstructionOrThrow(it.stringMatches!!.first().index) { + val reference = getReference() + reference?.parameterTypes?.firstOrNull() == "Landroid/content/Context;" + } + } navigate(miniplayerOverrideFingerprint.originalMethod).to(appNameStringIndex).stop().apply { findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride(index) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index ec30f3593..8e48c0918 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -27,7 +27,8 @@ val playerPopupPanelsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt index c2f3b5414..ca109ed20 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/PlayerControlsBackgroundPatch.kt @@ -18,7 +18,8 @@ val playerControlsBackgroundPatch = resourcePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt index 30daf219b..a546c0652 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/ExitFullscreenPatch.kt @@ -27,6 +27,7 @@ internal val exitFullscreenPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", + "20.12.46", ) ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt index 7e6166fd5..0735dbb1c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenPatch.kt @@ -27,6 +27,7 @@ val openVideosFullscreenPatch = bytecodePatch( "com.google.android.youtube"( "19.47.53", "20.07.39", + "20.12.46", ) ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt index 1c1b5b87c..dd78257eb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt @@ -58,7 +58,8 @@ val customPlayerOverlayOpacityPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/Fingerprints.kt index 23abbd2b1..3943d58ca 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/Fingerprints.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike import app.revanced.patcher.fingerprint +import app.revanced.util.literal import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -121,3 +122,12 @@ internal val textComponentLookupFingerprint = fingerprint { parameters("L") strings("…") } + +internal const val LITHO_NEW_TEXT_COMPONENT_FEATURE_FLAG = 45675738L + +internal val textComponentFeatureFlagFingerprint = fingerprint { + accessFlags(AccessFlags.FINAL) + returns("Z") + parameters() + literal { LITHO_NEW_TEXT_COMPONENT_FEATURE_FLAG } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 2d972d917..fc01bf804 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -12,6 +12,7 @@ import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch import app.revanced.patches.youtube.misc.playservice.is_19_33_or_greater +import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater import app.revanced.patches.youtube.misc.playservice.is_20_10_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.addSettingPreference @@ -59,7 +60,8 @@ val returnYouTubeDislikePatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { @@ -174,6 +176,14 @@ val returnYouTubeDislikePatch = bytecodePatch( // Filter that parses the video id from the UI addLithoFilter(FILTER_CLASS_DESCRIPTOR) + if (is_20_07_or_greater) { + // Turn off a/b flag that enables new code for creating litho spans. + // If enabled then the litho text span hook is never called. + // Target code is very obfuscated and exactly what the code does is not clear. + // Return late so debug patch logs if the flag is enabled. + textComponentFeatureFlagFingerprint.method.returnLate(false) + } + // Player response video id is needed to search for the video ids in Shorts litho components. hookPlayerResponseVideoId("$FILTER_CLASS_DESCRIPTOR->newPlayerResponseVideoId(Ljava/lang/String;Z)V") diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index 6bb9aad78..9df1c00eb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -35,7 +35,8 @@ val wideSearchbarPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt index 40a2c59d5..67bb3c159 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt @@ -39,7 +39,8 @@ val shortsAutoplayPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt index c9bf0043d..1198c4ce2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsplayer/OpenShortsInRegularPlayerPatch.kt @@ -47,7 +47,8 @@ val openShortsInRegularPlayerPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/Fingerprints.kt index 612ceb6c8..80eca0557 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/Fingerprints.kt @@ -20,12 +20,6 @@ internal val appendTimeFingerprint = fingerprint { Opcode.MOVE_RESULT_OBJECT, Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT, - Opcode.IF_NEZ, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN_VOID, ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt index e9f7e945c..832b70dcf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt @@ -114,7 +114,8 @@ val sponsorBlockPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index 9268ed086..486bb398d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -64,7 +64,8 @@ val spoofAppVersionPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt index 54106b5fc..f05254bed 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt @@ -35,7 +35,8 @@ val changeStartPagePatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index a8945a528..8c63cea88 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -40,7 +40,8 @@ val disableResumingShortsOnStartupPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/Fingerprints.kt index 9ed098a1b..a793eaa3c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/Fingerprints.kt @@ -10,13 +10,6 @@ internal val lithoThemeFingerprint = fingerprint { returns("V") parameters("Landroid/graphics/Rect;") opcodes( - Opcode.APUT, - Opcode.NEW_INSTANCE, - Opcode.INVOKE_DIRECT, - Opcode.IGET_OBJECT, - Opcode.SGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.IPUT_OBJECT, Opcode.IGET, Opcode.IF_EQZ, Opcode.INVOKE_VIRTUAL, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt index da0f29fc8..73e84d659 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt @@ -223,7 +223,8 @@ val themePatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index f86e19f38..805782f40 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -39,7 +39,8 @@ val alternativeThumbnailsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt index f353b7811..2563461cb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictionsPatch.kt @@ -33,7 +33,8 @@ val bypassImageRegionRestrictionsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt index d3ff7c1cd..b701cbc36 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt @@ -29,7 +29,8 @@ val announcementsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt index e29154e63..79384582b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt @@ -30,7 +30,8 @@ val autoRepeatPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt index 4826dc78b..45c2f061f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -57,7 +57,8 @@ val backgroundPlaybackPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt index b244f0dc9..f4facb097 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt @@ -40,7 +40,8 @@ val enableDebuggingPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index 2f9a2602b..e5c7bb459 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -30,7 +30,8 @@ val spoofDeviceDimensionsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt index 558d67674..ac523b63e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt @@ -27,7 +27,8 @@ val checkWatchHistoryDomainNameResolutionPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/Fingerprints.kt index fe8f4684a..21dfd84f8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/Fingerprints.kt @@ -9,9 +9,7 @@ internal val onBackPressedFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) opcodes(Opcode.RETURN_VOID) custom { method, classDef -> - method.name == "onBackPressed" && - // Old versions of YouTube called this class "WatchWhileActivity" instead. - (classDef.endsWith("MainActivity;") || classDef.endsWith("WatchWhileActivity;")) + method.name == "onBackPressed" && classDef.endsWith("MainActivity;") } } @@ -27,6 +25,9 @@ internal val scrollPositionFingerprint = fingerprint { strings("scroll_position") } +/** + * Resolves using class found in [recyclerViewTopScrollingParentFingerprint]. + */ internal val recyclerViewTopScrollingFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returns("V") diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index e80e804db..1c2246077 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -41,7 +41,8 @@ val gmsCoreSupportPatch = gmsCoreSupportPatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt index fdb65ff27..cd60eb645 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt @@ -38,7 +38,8 @@ val bypassURLRedirectsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt index 7d3cc99f4..3beb329e2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt @@ -47,7 +47,8 @@ val openLinksExternallyPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/Fingerprints.kt index 9df0cda0c..8a0bc3348 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/Fingerprints.kt @@ -47,11 +47,7 @@ internal val mainActivityOnBackPressedFingerprint = fingerprint { returns("V") parameters() custom { method, classDef -> - val matchesClass = classDef.endsWith("MainActivity;") || - // Old versions of YouTube called this class "WatchWhileActivity" instead. - classDef.endsWith("WatchWhileActivity;") - - matchesClass && method.name == "onBackPressed" + method.name == "onBackPressed" && classDef.endsWith("MainActivity;") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playservice/VersionCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playservice/VersionCheckPatch.kt index 2d76094af..9cdd5dd48 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playservice/VersionCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playservice/VersionCheckPatch.kt @@ -58,6 +58,10 @@ var is_20_09_or_greater = false private set var is_20_10_or_greater = false private set +var is_20_14_or_greater = false + private set +var is_20_15_or_greater = false + private set val versionCheckPatch = resourcePatch( description = "Uses the Play Store service version to find the major/minor version of the YouTube target app.", @@ -98,5 +102,7 @@ val versionCheckPatch = resourcePatch( is_20_07_or_greater = 250805000 <= playStoreServicesVersion is_20_09_or_greater = 251006000 <= playStoreServicesVersion is_20_10_or_greater = 251105000 <= playStoreServicesVersion + is_20_14_or_greater = 251505000 <= playStoreServicesVersion + is_20_15_or_greater = 251605000 <= playStoreServicesVersion } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt index 95897a8ab..1eb287abc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt @@ -36,7 +36,8 @@ val removeTrackingQueryParameterPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt index 27ccc881d..f75eef328 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/spoof/SpoofVideoStreamsPatch.kt @@ -9,6 +9,7 @@ import app.revanced.patches.shared.misc.spoof.spoofVideoStreamsPatch import app.revanced.patches.youtube.misc.playservice.is_19_34_or_greater import app.revanced.patches.youtube.misc.playservice.is_20_03_or_greater import app.revanced.patches.youtube.misc.playservice.is_20_10_or_greater +import app.revanced.patches.youtube.misc.playservice.is_20_14_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch @@ -22,7 +23,8 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch({ "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) dependsOn( @@ -33,7 +35,8 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch({ }, { is_19_34_or_greater }, { - is_20_10_or_greater + // In 20.14 the flag was merged with 20.03 start playback flag. + is_20_10_or_greater && !is_20_14_or_greater }, { is_20_03_or_greater }, { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt index 23d9ced21..0e961dfeb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt @@ -27,7 +27,8 @@ val zoomHapticsPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/shared/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/shared/Fingerprints.kt index a242d6fad..d0c7d30a2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/shared/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/shared/Fingerprints.kt @@ -33,8 +33,7 @@ internal val mainActivityFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR) parameters() custom { _, classDef -> - // Old versions of YouTube called this class "WatchWhileActivity" instead. - classDef.endsWith("MainActivity;") || classDef.endsWith("WatchWhileActivity;") + classDef.endsWith("MainActivity;") } } @@ -42,12 +41,7 @@ internal val mainActivityOnCreateFingerprint = fingerprint { returns("V") parameters("Landroid/os/Bundle;") custom { method, classDef -> - method.name == "onCreate" && - ( - classDef.endsWith("MainActivity;") || - // Old versions of YouTube called this class "WatchWhileActivity" instead. - classDef.endsWith("WatchWhileActivity;") - ) + method.name == "onCreate" && classDef.endsWith("MainActivity;") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ForceOriginalAudioPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ForceOriginalAudioPatch.kt index dcb83a963..461b8485a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ForceOriginalAudioPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/audio/ForceOriginalAudioPatch.kt @@ -47,7 +47,8 @@ val forceOriginalAudioPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/hdr/DisableHdrPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/hdr/DisableHdrPatch.kt index 76f996738..d83fcaa8f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/hdr/DisableHdrPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/hdr/DisableHdrPatch.kt @@ -34,7 +34,8 @@ val disableHdrPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", - ), + "20.12.46", + ) ) execute { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt index d0c961c9d..349f7300b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/Fingerprints.kt @@ -117,13 +117,6 @@ internal val playbackSpeedMenuSpeedChangedFingerprint = fingerprint { returns("L") parameters("L") opcodes( - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IF_EQZ, - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, Opcode.IGET, Opcode.INVOKE_VIRTUAL, Opcode.SGET_OBJECT, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/Fingerprints.kt index 562156fad..d958285b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/Fingerprints.kt @@ -5,9 +5,35 @@ import com.android.tools.smali.dexlib2.AccessFlags import org.stringtemplate.v4.compiler.Bytecode.instructions /** - * For targets 20.10 and later. + * For targets 20.15 and later. */ internal val playerParameterBuilderFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("L") + parameters( + "Ljava/lang/String;", // VideoId. + "[B", + "Ljava/lang/String;", // Player parameters proto buffer. + "Ljava/lang/String;", + "I", + "Z", + "I", + "L", + "Ljava/util/Set;", + "Ljava/lang/String;", + "Ljava/lang/String;", + "L", + "Z", // Appears to indicate if the video id is being opened or is currently playing. + "Z", + "Z" + ) + strings("psps") +} + +/** + * For targets 20.10 to 20.14. + */ +internal val playerParameterBuilder2010Fingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returns("L") parameters( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt index 4b02324bc..898f40096 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt @@ -9,6 +9,7 @@ import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.playservice.is_19_23_or_greater import app.revanced.patches.youtube.misc.playservice.is_20_02_or_greater import app.revanced.patches.youtube.misc.playservice.is_20_10_or_greater +import app.revanced.patches.youtube.misc.playservice.is_20_15_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch private val hooks = mutableSetOf() @@ -39,9 +40,12 @@ val playerResponseMethodHookPatch = bytecodePatch { execute { val fingerprint : Fingerprint - if (is_20_10_or_greater) { + if (is_20_15_or_greater) { parameterIsShortAndOpeningOrPlaying = 13 fingerprint = playerParameterBuilderFingerprint + } else if (is_20_10_or_greater) { + parameterIsShortAndOpeningOrPlaying = 13 + fingerprint = playerParameterBuilder2010Fingerprint } else if (is_20_02_or_greater) { parameterIsShortAndOpeningOrPlaying = 12 fingerprint = playerParameterBuilder2002Fingerprint diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt index bf696a7ef..3e292250a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt @@ -29,6 +29,7 @@ val videoQualityPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", + "20.12.46", ) ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt index d86cf49d6..2ea4ba0e8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt @@ -34,6 +34,7 @@ val playbackSpeedPatch = bytecodePatch( "19.43.41", "19.47.53", "20.07.39", + "20.12.46", ) ) diff --git a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index b0bd29fd7..c6de63c83 100644 --- a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -698,29 +698,54 @@ fun BytecodePatchContext.forEachLiteralValueInstruction( } /** - * Return the method early. + * Overrides the first instruction of a method with a constant return value. + * None of the method code will ever execute. */ -fun MutableMethod.returnEarly(bool: Boolean = false) { +fun MutableMethod.returnEarly(overrideValue: Boolean = false) = overrideReturnValue(overrideValue, false) + +/** + * Overrides all return statements with a constant value. + * All method code is executed the same as unpatched. + * + * @see returnEarly + */ +internal fun MutableMethod.returnLate(overrideValue: Boolean = false) = overrideReturnValue(overrideValue, true) + +private fun MutableMethod.overrideReturnValue(bool: Boolean, returnLate: Boolean) { val const = if (bool) "0x1" else "0x0" - val stringInstructions = when (returnType.first()) { - 'L' -> + val instructions = when (returnType.first()) { + 'L' -> { """ const/4 v0, $const return-object v0 """ + } - 'V' -> "return-void" - 'I', 'Z' -> + 'V' -> { + if (returnLate) throw IllegalArgumentException("Cannot return late for method of void type") + "return-void" + } + + 'I', 'Z' -> { """ const/4 v0, $const return v0 """ + } else -> throw Exception("Return type is not supported: $this") } - addInstructions(0, stringInstructions) + if (returnLate) { + findInstructionIndicesReversed { + opcode == RETURN || opcode == RETURN_OBJECT + }.forEach { index -> + addInstructionsAtControlFlowLabel(index, instructions) + } + } else { + addInstructions(0, instructions) + } } /**