From d20fde1e57077fe9a943f9782b415d7a0249b083 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 8 Jul 2023 03:02:32 +0400 Subject: [PATCH] feat(youtube): support version `18.23.35` (#2461) Co-authored-by: oSumAtrIX --- .../annotation/HideAdsCompatibility.kt | 2 +- .../HideGetPremiumCompatibility.kt | 2 +- .../annotations/VideoAdsCompatibility.kt | 2 +- .../annotation/CopyVideoUrlCompatibility.kt | 2 +- .../ExternalDownloadsCompatibility.kt | 2 +- .../annotation/SeekbarTappingCompatibility.kt | 2 +- .../annotation/SwipeControlsCompatibility.kt | 2 +- .../annotations/AutoCaptionsCompatibility.kt | 2 +- .../annotations/HideButtonsCompatibility.kt | 2 +- .../AutoplayButtonCompatibility.kt | 2 +- .../HideCaptionsButtonCompatibility.kt | 2 +- .../NavigationButtonsCompatibility.kt | 2 +- .../HidePlayerButtonsCompatibility.kt | 2 +- .../annotations/AlbumCardsCompatibility.kt | 2 +- .../annotations/BreakingNewsCompatibility.kt | 2 +- .../annotations/HideCommentsCompatibility.kt | 2 +- .../CrowdfundingBoxCompatibility.kt | 2 +- .../HideEndscreenCardsCompatibility.kt | 2 +- .../filterbar/annotations/HideFilterBar.kt | 2 +- ...deFloatingMicrophoneButtonCompatibility.kt | 2 +- .../HideLayoutComponentsCompatibility.kt | 2 +- .../annotations/HideInfocardsCompatibility.kt | 2 +- .../HideLoadMoreButtonCompatibility.kt | 2 +- .../HideEmailAddressCompatibility.kt | 2 +- .../CreatePlayerOverviewFingerprint.kt | 10 +- .../annotations/HideSeekbarCompatibility.kt | 2 +- .../HideShortsComponentsCompatibility.kt | 2 +- .../time/annotations/HideTimeCompatibility.kt | 2 +- .../annotations/WatchInVRCompatibility.kt | 2 +- .../annotations/HideWatermarkCompatibility.kt | 2 +- .../FullscreenPanelsCompatibility.kt | 2 +- .../PlayerPopupPanelsCompatibility.kt | 2 +- .../PlayerControlsBackgroundCompatibility.kt | 2 +- .../ReturnYouTubeDislikeCompatibility.kt | 2 +- ...TextComponentAtomicReferenceFingerprint.kt | 7 +- .../TextComponentContextFingerprint.kt | 2 +- .../annotations/WideSearchbarCompatibility.kt | 2 +- .../annotations/SponsorBlockCompatibility.kt | 2 +- .../SpoofAppVersionCompatibility.kt | 2 +- .../StartupShortsResetCompatibility.kt | 2 +- .../TabletMiniPlayerCompatibility.kt | 2 +- .../MiniPlayerOverrideFingerprint.kt | 2 +- .../MiniPlayerOverrideParentFingerprint.kt | 2 +- .../annotations/AutoRepeatCompatibility.kt | 2 +- .../CreateBottomSheetFingerprint.kt | 13 +++ .../hook/patch/BottomSheetHookPatch.kt | 43 ++++++++ .../FixBackToExitGestureCompatibility.kt | 2 +- .../annotations/ClientSpoofCompatibility.kt | 2 +- .../annotations/IntegrationsCompatibility.kt | 2 +- .../OpenLinksExternallyCompatibility.kt | 2 +- .../fingerprints/ProtobufBufferFingerprint.kt | 25 ----- .../ProtobufBufferReferenceFingerprint.kt | 18 +++ .../litho/filter/patch/LithoFilterPatch.kt | 103 +++++++++++++----- .../annotations/MicroGPatchCompatibility.kt | 2 +- .../MinimizedPlaybackCompatibility.kt | 2 +- .../MinimizedPlaybackSettingsFingerprint.kt | 2 +- ...imizedPlaybackSettingsParentFingerprint.kt | 7 +- .../annotation/PlayerControlsCompatibility.kt | 2 +- .../PlayerOverlaysHookCompatibility.kt | 2 +- .../annotation/PlayerTypeHookCompatibility.kt | 2 +- .../CustomVideoBufferCompatibility.kt | 2 +- .../annotations/HDRBrightnessCompatibility.kt | 2 +- .../VideoInformationCompatibility.kt | 2 +- .../patch/OldQualityLayoutPatch.kt | 44 -------- .../patch/OldQualityLayoutResourcePatch.kt | 36 ------ .../RememberVideoQualityCompatibility.kt | 2 +- .../NewVideoQualityChangedFingerprint.kt | 32 ++++++ ...dexMethodClassFieldReferenceFingerprint.kt | 3 + .../patch/RememberVideoQualityPatch.kt | 24 +++- .../patches/youtube/video/speed/VideoSpeed.kt | 2 - .../video/speed/VideoSpeedCompatibility.kt | 2 +- .../GetOldVideoSpeedsFingerprint.kt | 8 ++ .../ShowOldVideoSpeedMenuFingerprint.kt | 7 ++ ...ldVideoSpeedMenuIntegrationsFingerprint.kt | 7 ++ .../VideoSpeedPatchFingerprint.kt | 0 .../custom/patch/CustomVideoSpeedPatch.kt | 90 +++++++++++++-- .../annotation/VideoIdCompatibility.kt | 2 +- .../OldVideoQualityMenuCompatibility.kt} | 6 +- ...VideoQualityMenuViewInflateFingerprint.kt} | 8 +- .../patch/OldVideoQualityMenuPatch.kt | 73 +++++++++++++ .../patch/OldVideoQualityMenuResourcePatch.kt | 42 +++++++ 81 files changed, 499 insertions(+), 225 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferReferenceFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/NewVideoQualityChangedFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/VideoSpeedPatchFingerprint.kt rename src/main/kotlin/app/revanced/patches/youtube/video/{oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt => videoqualitymenu/annotations/OldVideoQualityMenuCompatibility.kt} (58%) rename src/main/kotlin/app/revanced/patches/youtube/video/{oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt => videoqualitymenu/fingerprints/VideoQualityMenuViewInflateFingerprint.kt} (69%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt index 798560a76..5f90c5019 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/annotation/HideAdsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.ad.general.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/annotations/HideGetPremiumCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/annotations/HideGetPremiumCompatibility.kt index 7f3958742..f17ebada9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/annotations/HideGetPremiumCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/annotations/HideGetPremiumCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.ad.getpremium.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideGetPremiumCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt index 6713227a1..9226b6f44 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/annotations/VideoAdsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.ad.video.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoAdsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt index fc46729a4..93058c896 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/annotation/CopyVideoUrlCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.interaction.copyvideourl.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class CopyVideoUrlCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt index 7dc840c61..be32f73c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/annotation/ExternalDownloadsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.downloads.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class ExternalDownloadsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt index 56a7b6893..cd1b8ca07 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/annotation/SeekbarTappingCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.seekbar.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SeekbarTappingCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt index feaa5effc..ad2ec1770 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/annotation/SwipeControlsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.interaction.swipecontrols.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SwipeControlsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt index c03a3e7f9..81fb60d32 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/annotations/AutoCaptionsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.autocaptions.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoCaptionsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt index 112725358..1c521c547 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/annotations/HideButtonsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.action.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideButtonsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt index 278fb0c2f..bb95ff038 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/annotations/AutoplayButtonCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.autoplay.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoplayButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt index 849d2e18e..fc1e112a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/annotations/HideCaptionsButtonCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.captions.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideCaptionsButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt index e298888c1..393ac1366 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/annotations/NavigationButtonsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.navigation.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class NavigationButtonsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt index 1f20ff2fb..15330096c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/annotations/HidePlayerButtonsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.buttons.player.hide.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HidePlayerButtonsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt index 1523ca1c2..889695eaa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/annotations/AlbumCardsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.albumcards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AlbumCardsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt index af446cfe8..635820ab5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/annotations/BreakingNewsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.breakingnews.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class BreakingNewsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt index 27f8151f0..6d8b3b3e3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/annotations/HideCommentsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.comments.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideCommentsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt index f6776877b..fe6894aa3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/annotations/CrowdfundingBoxCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.crowdfundingbox.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class CrowdfundingBoxCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt index 47d278010..206275896 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/annotations/HideEndscreenCardsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.endscreencards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideEndscreenCardsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt index e45cafd7b..95aa29f64 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/annotations/HideFilterBar.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.filterbar.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideFilterBar \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt index 8ab0a1e5c..b5f04f78a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/annotations/HideFloatingMicrophoneButtonCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.floatingmicrophone.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideFloatingMicrophoneButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/annotations/HideLayoutComponentsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/annotations/HideLayoutComponentsCompatibility.kt index 926b97920..a685bf3ee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/annotations/HideLayoutComponentsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/annotations/HideLayoutComponentsCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.hide.general.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideLayoutComponentsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt index 8a71676e9..520f038f6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/annotations/HideInfocardsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.infocards.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideInfocardsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt index 5c580599c..a9c4bcea7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/annotations/HideLoadMoreButtonCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.hide.loadmorebutton.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideLoadMoreButtonCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt index 27abf2723..3d7193394 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/annotations/HideEmailAddressCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.personalinformation.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideEmailAddressCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt index c22588a28..1325bee97 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/fingerprints/CreatePlayerOverviewFingerprint.kt @@ -1,12 +1,13 @@ package app.revanced.patches.youtube.layout.hide.player.overlay.bytecode.fingerprints +import app.revanced.extensions.containsConstantInstructionValue import app.revanced.patcher.extensions.or -import app.revanced.util.patch.LiteralValueFingerprint +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.hide.player.overlay.resource.patch.HidePlayerOverlayResourcePatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object CreatePlayerOverviewFingerprint : LiteralValueFingerprint( +object CreatePlayerOverviewFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, opcodes = listOf( @@ -15,5 +16,8 @@ object CreatePlayerOverviewFingerprint : LiteralValueFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - literal = HidePlayerOverlayResourcePatch.scrimOverlayId + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("YouTubeControlsOverlay;") + && methodDef.containsConstantInstructionValue(HidePlayerOverlayResourcePatch.scrimOverlayId) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt index 560e17a8e..784fa8611 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/annotations/HideSeekbarCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.seekbar.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideSeekbarCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt index a058e84cd..e434846d0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/annotations/HideShortsComponentsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.shorts.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideShortsComponentsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt index c3f3c7776..baa9be5ff 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/annotations/HideTimeCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.time.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideTimeCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt index 9eba5cc7c..e03bee708 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/annotations/WatchInVRCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.watchinvr.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class WatchInVRCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt index 8d11da21a..687b50654 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/annotations/HideWatermarkCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.hide.watermark.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HideWatermarkCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt index 86a2865c2..11dbf8842 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/annotations/FullscreenPanelsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.panels.fullscreen.remove.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class FullscreenPanelsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt index c05d454b4..e6da79902 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/annotations/PlayerPopupPanelsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.panels.popup.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerPopupPanelsCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/annotations/PlayerControlsBackgroundCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/annotations/PlayerControlsBackgroundCompatibility.kt index ac2062c55..d7e6490f9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/annotations/PlayerControlsBackgroundCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/background/annotations/PlayerControlsBackgroundCompatibility.kt @@ -2,6 +2,6 @@ package app.revanced.patches.youtube.layout.player.background.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerControlsBackgroundCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt index aa0f3fcc5..5f3dd157e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/annotations/ReturnYouTubeDislikeCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class ReturnYouTubeDislikeCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt index 199f14889..c5955c0f2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentAtomicReferenceFingerprint.kt @@ -21,14 +21,11 @@ object TextComponentAtomicReferenceFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, Opcode.MOVE_OBJECT, // CharSequence reference, and control flow label. Insert code here. - Opcode.INVOKE_VIRTUAL, + null, // invoke-interface or invoke-virtual Opcode.MOVE_RESULT, Opcode.IF_EQZ, - Opcode.INVOKE_VIRTUAL, + null, // invoke-interface or invoke-virtual Opcode.MOVE_RESULT_OBJECT, Opcode.GOTO, - Opcode.CONST_4, - Opcode.INVOKE_VIRTUAL_RANGE, - Opcode.MOVE_RESULT_OBJECT, ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentContextFingerprint.kt index eee7ab2a2..7e4d3141f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/TextComponentContextFingerprint.kt @@ -6,7 +6,7 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode /** - * Resolves against the same method that [TextComponentContextFingerprint] resolves to. + * Resolves against the same class that [TextComponentConstructorFingerprint] resolves to. */ object TextComponentContextFingerprint : MethodFingerprint( returnType = "L", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt index 75d3373ec..1fe97fe00 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/annotations/WideSearchbarCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.searchbar.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class WideSearchbarCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt index f805334ff..7eefbbd53 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/annotations/SponsorBlockCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.sponsorblock.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SponsorBlockCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt index c64f17745..04740e6fb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/annotations/SpoofAppVersionCompatibility.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.spoofappversion.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class SpoofAppVersionCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt index 72b516851..9b2022792 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/annotations/StartupShortsResetCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.startupshortsreset.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class StartupShortsResetCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt index ded1563ed..4284c94d0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/annotations/TabletMiniPlayerCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class TabletMiniPlayerCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt index e43e1770f..f2210f76b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt @@ -7,7 +7,7 @@ import org.jf.dexlib2.Opcode object MiniPlayerOverrideFingerprint : MethodFingerprint( "Z", AccessFlags.STATIC or AccessFlags.PUBLIC, - listOf("L"), + listOf("Landroid/content/Context;"), opcodes = listOf( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideParentFingerprint.kt index a4180746c..df5352235 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/fingerprints/MiniPlayerOverrideParentFingerprint.kt @@ -3,5 +3,5 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint object MiniPlayerOverrideParentFingerprint : MethodFingerprint( - strings = listOf("Possible Context wrapper loop - chain of wrappers larger than 10000") + strings = listOf("Unset or unknown Input OneOf case for dynamic input") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt index ab04bfe8d..b4b62674c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/annotations/AutoRepeatCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.autorepeat.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class AutoRepeatCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt new file mode 100644 index 000000000..70c04aa39 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patches.youtube.video.videoqualitymenu.patch.OldVideoQualityMenuResourcePatch +import app.revanced.util.patch.LiteralValueFingerprint +import org.jf.dexlib2.AccessFlags + +object CreateBottomSheetFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + returnType = "Landroid/widget/LinearLayout;", + literal = OldVideoQualityMenuResourcePatch.bottomSheetMargins +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt new file mode 100644 index 000000000..d72b974ef --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt @@ -0,0 +1,43 @@ +package app.revanced.patches.youtube.misc.bottomsheet.hook.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints.CreateBottomSheetFingerprint +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@DependsOn([IntegrationsPatch::class]) +class BottomSheetHookPatch : BytecodePatch( + listOf(CreateBottomSheetFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + CreateBottomSheetFingerprint.result?.let { + it.mutableMethod.apply { + val returnLinearLayoutIndex = implementation!!.instructions.lastIndex + val linearLayoutRegister = getInstruction(returnLinearLayoutIndex).registerA + + addHook = { classDescriptor -> + addInstruction( + returnLinearLayoutIndex, + "invoke-static { v$linearLayoutRegister }, " + + "${classDescriptor}->" + + "onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V" + ) + } + } + } ?: return CreateBottomSheetFingerprint.toErrorResult() + + return PatchResultSuccess() + } + + internal companion object { + internal lateinit var addHook: (String) -> Unit + private set + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt index 8a470352b..bce548f11 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/annotation/FixBackToExitGestureCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class FixBackToExitGestureCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt index 13e9c51b5..24c49518a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/annotations/ClientSpoofCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.fix.playback.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class ClientSpoofCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt index 0bdca1b8a..9de9f53c3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/annotations/IntegrationsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.integrations.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class IntegrationsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt index 9485b3efc..233b8ce6a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/annotations/OpenLinksExternallyCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.links.open.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class OpenLinksExternallyCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferFingerprint.kt deleted file mode 100644 index 9e0997936..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferFingerprint.kt +++ /dev/null @@ -1,25 +0,0 @@ -package app.revanced.patches.youtube.misc.litho.filter.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.Opcode - -object ProtobufBufferFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.IGET_OBJECT, // References the field required below. - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - Opcode.IF_NEZ, - Opcode.CONST_4, - Opcode.GOTO, - Opcode.CHECK_CAST, // Casts the referenced field to a specific type that stores the protobuf buffer. - Opcode.INVOKE_VIRTUAL - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferReferenceFingerprint.kt new file mode 100644 index 000000000..aeecb9e2a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ProtobufBufferReferenceFingerprint.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.youtube.misc.litho.filter.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object ProtobufBufferReferenceFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("I", "Ljava/nio/ByteBuffer;"), + opcodes = listOf( + Opcode.IPUT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.SUB_INT_2ADDR + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt index 2b709072d..59848db09 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt @@ -4,50 +4,110 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.litho.filter.fingerprints.* +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.immutable.ImmutableField import java.io.Closeable @DependsOn([IntegrationsPatch::class]) @Description("Hooks the method which parses the bytes into a ComponentContext to filter components.") @Version("0.0.1") class LithoFilterPatch : BytecodePatch( - listOf(ComponentContextParserFingerprint, LithoFilterFingerprint) + listOf(ComponentContextParserFingerprint, LithoFilterFingerprint, ProtobufBufferReferenceFingerprint) ), Closeable { + /** + * The following patch inserts a hook into the method that parses the bytes into a ComponentContext. + * This method contains a StringBuilder object that represents the pathBuilder of the component. + * The pathBuilder is used to filter components by their path. + * + * Additionally, the method contains a reference to the components identifier. + * The identifier is used to filter components by their identifier. + * + * In addition to that, a static field is added to the class of this method. (See protobufBufferField). + * This field holds a reference to the protobuf buffer object. + * The field is being set in another method that holds a reference to the protobuf buffer object. + * The object contains a large byte array that represents the component tree. + * This byte array is searched for strings that indicate the current component. + * + * The following pseudo code shows how the patch works: + * + * class ComponentContextParser { + * public static ByteBuffer buffer; // Inserted by this patch. + * + * public ComponentContext parseBytesToComponentContext(...) { + * ... + * if (filter(identifier, pathBuilder, buffer)); // Inserted by this patch. + * return emptyComponent; + * ... + * } + * } + * + * class SomeOtherClass { + * // Called before ComponentContextParser.parseBytesToComponentContext method. + * public void someOtherMethod(ByteBuffer byteBuffer) { + * ComponentContextParser.buffer = byteBuffer; // Inserted by this patch. + * ... + * } + * } + */ override fun execute(context: BytecodeContext): PatchResult { ComponentContextParserFingerprint.result?.also { arrayOf( EmptyComponentBuilderFingerprint, - ReadComponentIdentifierFingerprint, - ProtobufBufferFingerprint + ReadComponentIdentifierFingerprint ).forEach { fingerprint -> if (fingerprint.resolve(context, it.mutableMethod, it.mutableClass)) return@forEach return fingerprint.toErrorResult() } - }?.let { result -> + }?.let { bytesToComponentContextMethod -> + // region Add a static field that holds a reference to the protobuf buffer object. + val protobufBufferField = ImmutableField( + bytesToComponentContextMethod.mutableClass.type, + "buffer", + "Ljava/nio/ByteBuffer;", + AccessFlags.PUBLIC or AccessFlags.STATIC, + null, + null, + null + ).toMutable() + bytesToComponentContextMethod.mutableClass.staticFields.add(protobufBufferField) + + // Set the field with the reference to the protobuf buffer object. + ProtobufBufferReferenceFingerprint.result + ?.mutableMethod?.addInstruction(0, "sput-object p2, $protobufBufferField") + ?: return ProtobufBufferReferenceFingerprint.toErrorResult() + + // endregion + + // region Hook the method that parses bytes into a ComponentContext. + val builderMethodIndex = EmptyComponentBuilderFingerprint.patternScanEndIndex val emptyComponentFieldIndex = builderMethodIndex + 2 - result.mutableMethod.apply { - val insertHookIndex = result.scanResult.patternScanResult!!.endIndex + bytesToComponentContextMethod.mutableMethod.apply { + val insertHookIndex = bytesToComponentContextMethod.scanResult.patternScanResult!!.endIndex - // region Get free registers that this patch uses + // region Get free registers that this patch uses. // Registers are overwritten right after they are used in this patch, therefore free to clobber. val freeRegistersInstruction = getInstruction(insertHookIndex - 2) @@ -64,7 +124,7 @@ class LithoFilterPatch : BytecodePatch( // endregion - // region Get references that this patch needs + // region Get references that this patch needs. val builderMethodDescriptor = getInstruction(builderMethodIndex).descriptor val emptyComponentFieldDescriptor = getInstruction(emptyComponentFieldIndex).descriptor @@ -72,34 +132,18 @@ class LithoFilterPatch : BytecodePatch( val identifierRegister = getInstruction(ReadComponentIdentifierFingerprint.patternScanEndIndex).registerA - // Parameter that holds a ref to a type with a field that ref the protobuf buffer object. - val protobufParameterNumber = 3 - - // Get the field that stores an protobuf buffer required below. - val protobufBufferRefTypeRefFieldDescriptor = - getInstruction(ProtobufBufferFingerprint.patternScanStartIndex).descriptor - val protobufBufferRefTypeDescriptor = - getInstruction(ProtobufBufferFingerprint.patternScanEndIndex - 1).descriptor - val protobufBufferFieldDescriptor = "$protobufBufferRefTypeDescriptor->b:Ljava/nio/ByteBuffer;" - // endregion - // region Patch the method + // region Patch the method. // Insert the instructions that are responsible // to return an EmptyComponent instead of the original component if the filter method returns false. addInstructionsWithLabels( insertHookIndex, """ - # Get the protobuf buffer object. - - move-object/from16 v$free1, p$protobufParameterNumber - iget-object v$free1, v$free1, $protobufBufferRefTypeRefFieldDescriptor - check-cast v$free1, $protobufBufferRefTypeDescriptor - - # Register "free" now holds the protobuf buffer object + # Register "free1" holds the protobuf buffer object - iget-object v$free1, v$free1, $protobufBufferFieldDescriptor + sget-object v$free1, $protobufBufferField # Invoke the filter method. @@ -119,6 +163,8 @@ class LithoFilterPatch : BytecodePatch( ) // endregion } + + // endregion } ?: return ComponentContextParserFingerprint.toErrorResult() LithoFilterFingerprint.result?.mutableMethod?.apply { @@ -150,9 +196,6 @@ class LithoFilterPatch : BytecodePatch( private val MethodFingerprint.patternScanEndIndex get() = patternScanResult.endIndex - private val MethodFingerprint.patternScanStartIndex - get() = patternScanResult.startIndex - private val Instruction.descriptor get() = (this as ReferenceInstruction).reference.toString() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt index 352ed3746..30383fbf3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/annotations/MicroGPatchCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.microg.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class MicroGPatchCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt index 88bff32b0..782a7709c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/annotations/MinimizedPlaybackCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.minimizedplayback.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class MinimizedPlaybackCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt index ca676e7a3..a184fe77d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt @@ -6,7 +6,7 @@ import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode object MinimizedPlaybackSettingsFingerprint : MethodFingerprint( - returnType = "L", + returnType = "Ljava/lang/String;", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf(), opcodes = listOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt index 59754a7fd..180547a2e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsParentFingerprint.kt @@ -8,7 +8,8 @@ import org.jf.dexlib2.AccessFlags * Class fingerprint for [MinimizedPlaybackSettingsFingerprint] */ object MinimizedPlaybackSettingsParentFingerprint : MethodFingerprint( - accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, - parameters = listOf("Landroid/content/Context;", "Landroid/support/v4/media/session/MediaSessionCompat"), - strings = listOf("sessionToken must not be null") + accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, + returnType = "I", + parameters = listOf(), + strings = listOf("BiometricManager", "Failure in canAuthenticate(). FingerprintManager was null.") ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt index 296b6477b..311f48506 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/annotation/PlayerControlsCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playercontrols.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerControlsCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt index 89a6fa3d4..f65f81708 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/annotation/PlayerOverlaysHookCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playeroverlay.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerOverlaysHookCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt index dff4ca516..8630c376b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/annotation/PlayerTypeHookCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.misc.playertype.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class PlayerTypeHookCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt index 628499d60..d1c317def 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/annotations/CustomVideoBufferCompatibility.kt @@ -4,6 +4,6 @@ import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package // TODO: delete this -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class CustomVideoBufferCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt index 29e7da076..85bb22dcf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/annotations/HDRBrightnessCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.hdrbrightness.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class HDRBrightnessCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt index 2ff6163df..1b52f4df0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/annotation/VideoInformationCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.information.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoInformationCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt deleted file mode 100644 index 7f9d1b77f..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ /dev/null @@ -1,44 +0,0 @@ -package app.revanced.patches.youtube.video.oldqualitylayout.patch - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import app.revanced.patches.youtube.video.oldqualitylayout.annotations.OldQualityLayoutCompatibility -import app.revanced.patches.youtube.video.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint -import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction - -@Patch -@DependsOn([IntegrationsPatch::class, OldQualityLayoutResourcePatch::class]) -@Name("old-quality-layout") -@Description("Enables the original video quality flyout in the video player settings.") -@OldQualityLayoutCompatibility -@Version("0.0.1") -class OldQualityLayoutPatch : BytecodePatch(listOf(QualityMenuViewInflateFingerprint)) { - override fun execute(context: BytecodeContext): PatchResult { - val inflateFingerprintResult = QualityMenuViewInflateFingerprint.result!! - val method = inflateFingerprintResult.mutableMethod - val instructions = method.implementation!!.instructions - - // at this index the listener is added to the list view - val listenerInvokeRegister = instructions.size - 1 - 1 - - // get the register which stores the quality menu list view - val onItemClickViewRegister = (instructions[listenerInvokeRegister] as FiveRegisterInstruction).registerC - - // insert the integrations method - method.addInstruction( - listenerInvokeRegister, // insert the integrations instructions right before the listener - "invoke-static { v$onItemClickViewRegister }, Lapp/revanced/integrations/patches/playback/quality/OldQualityLayoutPatch;->showOldQualityMenu(Landroid/widget/ListView;)V" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt deleted file mode 100644 index 965486ce5..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutResourcePatch.kt +++ /dev/null @@ -1,36 +0,0 @@ -package app.revanced.patches.youtube.video.oldqualitylayout.patch - -import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultError -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch - -@DependsOn([SettingsPatch::class, ResourceMappingPatch::class]) -class OldQualityLayoutResourcePatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference( - "revanced_show_old_video_menu", - StringResource("revanced_show_old_video_menu_title", "Use old video quality player menu"), - StringResource("revanced_show_old_video_menu_summary_on", "Old video quality menu is used"), - StringResource("revanced_show_old_video_menu_summary_off", "Old video quality menu is not used") - ) - ) - - videoQualityBottomSheetListFragmentTitle = - ResourceMappingPatch.resourceMappings.find { it.name == "video_quality_bottom_sheet_list_fragment_title" } - ?.id ?: return PatchResultError("Could not find resource") - - return PatchResultSuccess() - } - - internal companion object { - var videoQualityBottomSheetListFragmentTitle = -1L - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt index 789e422eb..deb0185e9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/annotations/RememberVideoQualityCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.quality.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class RememberVideoQualityCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/NewVideoQualityChangedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/NewVideoQualityChangedFingerprint.kt new file mode 100644 index 000000000..f1dcf0a5b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/NewVideoQualityChangedFingerprint.kt @@ -0,0 +1,32 @@ +package app.revanced.patches.youtube.video.quality.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object NewVideoQualityChangedFingerprint : MethodFingerprint( + returnType = "L", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + opcodes = listOf( + Opcode.IGET, // Video resolution (human readable). + Opcode.IGET_OBJECT, + Opcode.IGET_BOOLEAN, + Opcode.IGET_OBJECT, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_DIRECT, + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.GOTO, + Opcode.CONST_4, + Opcode.IF_NE, + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IGET, + ) +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/SetQualityByIndexMethodClassFieldReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/SetQualityByIndexMethodClassFieldReferenceFingerprint.kt index d69bb8406..a4707a492 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/SetQualityByIndexMethodClassFieldReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/fingerprints/SetQualityByIndexMethodClassFieldReferenceFingerprint.kt @@ -3,6 +3,9 @@ package app.revanced.patches.youtube.video.quality.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode +/** + * Resolves with the class found in [VideoQualitySetterFingerprint]. + */ object SetQualityByIndexMethodClassFieldReferenceFingerprint : MethodFingerprint( returnType = "V", parameters = listOf("L"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt index 2877f39a1..43d32f8fe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt @@ -7,6 +7,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -22,10 +23,12 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch import app.revanced.patches.youtube.video.quality.annotations.RememberVideoQualityCompatibility +import app.revanced.patches.youtube.video.quality.fingerprints.NewVideoQualityChangedFingerprint import app.revanced.patches.youtube.video.quality.fingerprints.SetQualityByIndexMethodClassFieldReferenceFingerprint import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualityItemOnClickParentFingerprint import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualitySetterFingerprint import org.jf.dexlib2.iface.instruction.ReferenceInstruction +import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.reference.FieldReference @Patch @@ -37,7 +40,8 @@ import org.jf.dexlib2.iface.reference.FieldReference class RememberVideoQualityPatch : BytecodePatch( listOf( VideoQualitySetterFingerprint, - VideoQualityItemOnClickParentFingerprint + VideoQualityItemOnClickParentFingerprint, + NewVideoQualityChangedFingerprint ) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -113,6 +117,7 @@ class RememberVideoQualityPatch : BytecodePatch( VideoInformationPatch.onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "newVideoStarted") + // Inject a call to set the remembered quality once a video loads. VideoQualitySetterFingerprint.result?.also { if (!SetQualityByIndexMethodClassFieldReferenceFingerprint.resolve(context, it.classDef)) @@ -159,6 +164,7 @@ class RememberVideoQualityPatch : BytecodePatch( ) } ?: return VideoQualitySetterFingerprint.toErrorResult() + // Inject a call to remember the selected quality. VideoQualityItemOnClickParentFingerprint.result?.let { val onItemClickMethod = it.mutableClass.methods.find { method -> method.name == "onItemClick" } @@ -172,6 +178,22 @@ class RememberVideoQualityPatch : BytecodePatch( ) } ?: return PatchResultError("Failed to find onItemClick method") } ?: return VideoQualityItemOnClickParentFingerprint.toErrorResult() + + + // Remember video quality if not using old layout menu. + NewVideoQualityChangedFingerprint.result?.apply { + mutableMethod.apply { + val index = scanResult.patternScanResult!!.startIndex + val qualityRegister = getInstruction(index).registerA + + addInstruction( + index + 1, + "invoke-static {v$qualityRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedQualityInNewFlyout(I)V" + ) + } + } ?: return NewVideoQualityChangedFingerprint.toErrorResult() + + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt index a079bd0f3..5c5cfff30 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt @@ -19,9 +19,7 @@ import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackS @VideoSpeedCompatibility @Version("0.0.1") class VideoSpeed : BytecodePatch() { - override fun execute(context: BytecodeContext): PatchResult { return PatchResultSuccess() // All patches this patch depends on succeed. } - } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt index b97e92931..4072fa4db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.speed import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoSpeedCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt new file mode 100644 index 000000000..233d1d09d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/GetOldVideoSpeedsFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.video.speed.custom.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object GetOldVideoSpeedsFingerprint : MethodFingerprint( + parameters = listOf("[L", "I"), + strings = listOf("menu_item_playback_speed") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt new file mode 100644 index 000000000..3844ab32d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.video.speed.custom.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object ShowOldVideoSpeedMenuFingerprint : MethodFingerprint( + strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt new file mode 100644 index 000000000..a672dff90 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/ShowOldVideoSpeedMenuIntegrationsFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.video.speed.custom.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object ShowOldVideoSpeedMenuIntegrationsFingerprint : MethodFingerprint( + customFingerprint = { method, _ -> method.name == "showOldVideoSpeedMenu" } +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/VideoSpeedPatchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/fingerprints/VideoSpeedPatchFingerprint.kt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt index 73d02788c..b166c819c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt @@ -1,36 +1,46 @@ package app.revanced.patches.youtube.video.speed.custom.patch +import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.TextPreference +import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable +import app.revanced.patches.shared.settings.preference.impl.* +import app.revanced.patches.youtube.misc.bottomsheet.hook.patch.BottomSheetHookPatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch -import app.revanced.patches.youtube.video.speed.custom.fingerprints.SpeedArrayGeneratorFingerprint -import app.revanced.patches.youtube.video.speed.custom.fingerprints.SpeedLimiterFingerprint +import app.revanced.patches.youtube.video.speed.custom.fingerprints.* +import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.MethodReference +import org.jf.dexlib2.immutable.ImmutableField @Name("custom-video-speed") @Description("Adds custom video speed options.") -@DependsOn([IntegrationsPatch::class]) +@DependsOn([IntegrationsPatch::class, LithoFilterPatch::class, SettingsPatch::class, BottomSheetHookPatch::class]) @Version("0.0.1") class CustomVideoSpeedPatch : BytecodePatch( listOf( - SpeedArrayGeneratorFingerprint, SpeedLimiterFingerprint + SpeedArrayGeneratorFingerprint, + SpeedLimiterFingerprint, + GetOldVideoSpeedsFingerprint, + ShowOldVideoSpeedMenuIntegrationsFingerprint ) ) { @@ -45,7 +55,7 @@ class CustomVideoSpeedPatch : BytecodePatch( inputType = InputType.TEXT_MULTI_LINE, summary = StringResource( "revanced_custom_playback_speeds_summary", - "Add or change the video speeds available" + "Add or change the available playback speeds" ) ) ) @@ -71,7 +81,7 @@ class CustomVideoSpeedPatch : BytecodePatch( val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA - val videoSpeedsArrayType = "Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->customVideoSpeeds:[F" + val videoSpeedsArrayType = "$INTEGRATIONS_CLASS_DESCRIPTOR->customVideoSpeeds:[F" arrayGenMethod.addInstructions( arrayLengthConstIndex + 1, @@ -111,14 +121,72 @@ class CustomVideoSpeedPatch : BytecodePatch( // edit: alternatively this might work by overriding with fixed values such as 0.1x and 10x limiterMethod.replaceInstruction( limiterMinConstIndex, - "sget v$limiterMinConstDestination, Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->minVideoSpeed:F" + "sget v$limiterMinConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->minVideoSpeed:F" ) limiterMethod.replaceInstruction( limiterMaxConstIndex, - "sget v$limiterMaxConstDestination, Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->maxVideoSpeed:F" + "sget v$limiterMaxConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->maxVideoSpeed:F" ) + // region Force old video quality menu. + // This is necessary, because there is no known way of adding custom video speeds to the new menu. + + BottomSheetHookPatch.addHook(INTEGRATIONS_CLASS_DESCRIPTOR) + + // Required to check if the video speed menu is currently shown. + LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) + + GetOldVideoSpeedsFingerprint.result?.let { result -> + // Add a static INSTANCE field to the class. + // This is later used to call "showOldVideoSpeedMenu" on the instance. + val instanceField = ImmutableField( + result.classDef.type, + "INSTANCE", + result.classDef.type, + AccessFlags.PUBLIC or AccessFlags.STATIC, + null, + null, + null + ).toMutable() + + result.mutableClass.staticFields.add(instanceField) + // Set the INSTANCE field to the instance of the class. + // In order to prevent a conflict with another patch, add the instruction at index 1. + result.mutableMethod.addInstruction(1, "sput-object p0, $instanceField") + + // Get the "showOldVideoSpeedMenu" method. + // This is later called on the field INSTANCE. + val showOldVideoSpeedMenuMethod = ShowOldVideoSpeedMenuFingerprint.also { + if (!it.resolve(context, result.classDef)) + throw ShowOldVideoSpeedMenuFingerprint.toErrorResult() + }.result!!.method.toString() + + // Insert the call to the "showOldVideoSpeedMenu" method on the field INSTANCE. + ShowOldVideoSpeedMenuIntegrationsFingerprint.result?.mutableMethod?.apply { + addInstructionsWithLabels( + implementation!!.instructions.lastIndex, + """ + sget-object v0, $instanceField + if-nez v0, :not_null + return-void + :not_null + invoke-virtual { v0 }, $showOldVideoSpeedMenuMethod + """ + ) + } ?: return ShowOldVideoSpeedMenuIntegrationsFingerprint.toErrorResult() + } ?: return GetOldVideoSpeedsFingerprint.toErrorResult() + + // endregion + return PatchResultSuccess() } + private companion object { + private const val FILTER_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/patches/components/VideoSpeedMenuFilterPatch;" + + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;" + + } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt index 660f7d8ad..a5fa69c6f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/annotation/VideoIdCompatibility.kt @@ -3,6 +3,6 @@ package app.revanced.patches.youtube.video.videoid.annotation import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35", "18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) internal annotation class VideoIdCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/annotations/OldVideoQualityMenuCompatibility.kt similarity index 58% rename from src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/annotations/OldVideoQualityMenuCompatibility.kt index 701f9974d..5fe280f94 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/annotations/OldQualityLayoutCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/annotations/OldVideoQualityMenuCompatibility.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.youtube.video.oldqualitylayout.annotations +package app.revanced.patches.youtube.video.videoqualitymenu.annotations import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package -@Compatibility([Package("com.google.android.youtube", arrayOf("18.16.37", "18.19.35"))]) +@Compatibility([Package("com.google.android.youtube", arrayOf("18.20.39", "18.23.35"))]) @Target(AnnotationTarget.CLASS) -internal annotation class OldQualityLayoutCompatibility \ No newline at end of file +internal annotation class OldVideoQualityMenuCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/fingerprints/VideoQualityMenuViewInflateFingerprint.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/fingerprints/VideoQualityMenuViewInflateFingerprint.kt index e671f4c4e..4e2424a33 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/fingerprints/VideoQualityMenuViewInflateFingerprint.kt @@ -1,12 +1,12 @@ -package app.revanced.patches.youtube.video.oldqualitylayout.fingerprints +package app.revanced.patches.youtube.video.videoqualitymenu.fingerprints import app.revanced.patcher.extensions.or +import app.revanced.patches.youtube.video.videoqualitymenu.patch.OldVideoQualityMenuResourcePatch import app.revanced.util.patch.LiteralValueFingerprint -import app.revanced.patches.youtube.video.oldqualitylayout.patch.OldQualityLayoutResourcePatch import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -object QualityMenuViewInflateFingerprint : LiteralValueFingerprint( +object VideoQualityMenuViewInflateFingerprint : LiteralValueFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L", "L", "L"), returnType = "L", @@ -26,5 +26,5 @@ object QualityMenuViewInflateFingerprint : LiteralValueFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST ), - literal = OldQualityLayoutResourcePatch.videoQualityBottomSheetListFragmentTitle + literal = OldVideoQualityMenuResourcePatch.videoQualityBottomSheetListFragmentTitle ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuPatch.kt new file mode 100644 index 000000000..b304d1c36 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuPatch.kt @@ -0,0 +1,73 @@ +package app.revanced.patches.youtube.video.videoqualitymenu.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.youtube.misc.bottomsheet.hook.patch.BottomSheetHookPatch +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch +import app.revanced.patches.youtube.video.videoqualitymenu.annotations.OldVideoQualityMenuCompatibility +import app.revanced.patches.youtube.video.videoqualitymenu.fingerprints.VideoQualityMenuViewInflateFingerprint +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch +@DependsOn([ + IntegrationsPatch::class, + OldVideoQualityMenuResourcePatch::class, + LithoFilterPatch::class, + BottomSheetHookPatch::class +]) +@Name("old-video-quality-menu") +@Description("Shows the old video quality with the advanced video quality options instead of the new one.") +@OldVideoQualityMenuCompatibility +@Version("0.0.1") +class OldVideoQualityMenuPatch : BytecodePatch( + listOf(VideoQualityMenuViewInflateFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + // region Patch for the old type of the video quality menu. + + VideoQualityMenuViewInflateFingerprint.result?.let { + it.mutableMethod.apply { + val checkCastIndex = it.scanResult.patternScanResult!!.endIndex + val listViewRegister = getInstruction(checkCastIndex).registerA + + addInstruction( + checkCastIndex + 1, + "invoke-static { v$listViewRegister }, " + + "$INTEGRATIONS_CLASS_DESCRIPTOR->" + + "showOldVideoQualityMenu(Landroid/widget/ListView;)V" + ) + } + } + + // endregion + + // region Patch for the new type of the video quality menu. + + BottomSheetHookPatch.addHook(INTEGRATIONS_CLASS_DESCRIPTOR) + + // Required to check if the video quality menu is currently shown in order to click on the "Advanced" item. + LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) + + // endregion + + return PatchResultSuccess() + } + + private companion object { + private const val FILTER_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/patches/components/VideoQualityMenuFilterPatch;" + + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/patches/playback/quality/OldVideoQualityMenuPatch;" + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt new file mode 100644 index 000000000..52365b74b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt @@ -0,0 +1,42 @@ +package app.revanced.patches.youtube.video.videoqualitymenu.patch + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch +import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch + +@DependsOn([SettingsPatch::class, ResourceMappingPatch::class]) +class OldVideoQualityMenuResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + SettingsPatch.PreferenceScreen.VIDEO.addPreferences( + SwitchPreference( + "revanced_show_old_video_quality_menu", + StringResource("revanced_show_old_video_quality_menu_title", "Show old video quality menu"), + StringResource("revanced_show_old_video_quality_menu_summary_on", "Old video quality menu is shown"), + StringResource("revanced_show_old_video_quality_menu_summary_off", "New video quality menu is hidden") + ) + ) + + fun findResource(name: String) = ResourceMappingPatch.resourceMappings.find { it.name == name }?.id + ?: throw PatchResultError("Could not find resource") + + // Used for the old type of the video quality menu. + videoQualityBottomSheetListFragmentTitle = findResource("video_quality_bottom_sheet_list_fragment_title") + + // Used for the new type of the video quality menu. + bottomSheetMargins = findResource("bottom_sheet_margins") + + return PatchResultSuccess() + } + + internal companion object { + var videoQualityBottomSheetListFragmentTitle = -1L + var bottomSheetMargins = -1L + } +}