From 6da8a69f22c80dfc6296b49fd6a78847764ea8c6 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 23 Jan 2026 23:45:59 +0100 Subject: [PATCH] instructionMathes -> indices --- .../app/revanced/patches/disneyplus/Fingerprints.kt | 2 -- .../permanentrepeat/PermanentRepeatPatch.kt | 8 ++++---- .../music/layout/premium/HideGetPremiumPatch.kt | 10 +++++----- .../shared/misc/fix/verticalscroll/Fingerprints.kt | 11 +++-------- .../misc/fix/verticalscroll/VerticalScrollPatch.kt | 2 +- .../patches/tumblr/fixes/FixOldVersionsPatch.kt | 2 +- .../interaction/downloads/UnlockDownloadsPatch.kt | 2 +- .../dialog/RemoveViewerDiscretionDialogPatch.kt | 2 +- .../interaction/seekbar/EnableSeekbarTappingPatch.kt | 4 ++-- .../interaction/seekbar/EnableSlideToSeekPatch.kt | 4 ++-- .../interaction/swipecontrols/SwipeControlsPatch.kt | 2 +- .../buttons/overlay/HidePlayerOverlayButtonsPatch.kt | 2 +- .../layout/formfactor/ChangeFormFactorPatch.kt | 2 +- .../hide/endscreencards/HideEndScreenCardsPatch.kt | 2 +- .../HideEndScreenSuggestedVideoPatch.kt | 2 +- .../layout/hide/general/HideLayoutComponentsPatch.kt | 10 +++++----- .../layout/hide/infocards/HideInfoCardsPatch.kt | 2 +- .../DisableRollingNumberAnimationPatch.kt | 2 +- .../layout/hide/shorts/HideShortsComponentsPatch.kt | 4 ++-- .../youtube/layout/miniplayer/MiniplayerPatch.kt | 6 +++--- .../fullscreen/OpenVideosFullscreenHookPatch.kt | 4 ++-- .../player/overlay/CustomPlayerOverlayOpacityPatch.kt | 2 +- .../returnyoutubedislike/ReturnYouTubeDislikePatch.kt | 4 ++-- .../youtube/layout/seekbar/SeekbarColorPatch.kt | 6 +++--- .../layout/shortsautoplay/ShortsAutoplayPatch.kt | 2 +- .../layout/spoofappversion/SpoofAppVersionPatch.kt | 2 +- .../backtoexitgesture/FixBackToExitGesturePatch.kt | 2 +- .../misc/gms/AccountCredentialsInvalidTextPatch.kt | 2 +- .../youtube/misc/litho/filter/LithoFilterPatch.kt | 2 +- .../patches/youtube/misc/loopvideo/LoopVideoPatch.kt | 2 +- .../youtube/misc/navigation/NavigationBarHookPatch.kt | 6 +++--- .../misc/playercontrols/PlayerControlsPatch.kt | 6 +++--- .../youtube/misc/playertype/PlayerTypeHookPatch.kt | 2 +- .../video/quality/AdvancedVideoQualityMenuPatch.kt | 2 +- 34 files changed, 59 insertions(+), 66 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt index 94d999c5e..11607b361 100644 --- a/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt @@ -6,7 +6,6 @@ import app.revanced.patcher.name import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.returnType - internal val BytecodePatchContext.insertionGetPointsMethod by gettingFirstMutableMethodDeclaratively { name("getPoints") definingClass("Lcom/dss/sdk/internal/media/Insertion;") @@ -18,4 +17,3 @@ internal val BytecodePatchContext.insertionGetRangesMethod by gettingFirstMutabl definingClass("Lcom/dss/sdk/internal/media/Insertion;") returnType("Ljava/util/List") } - diff --git a/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt index e1b72706e..9468af69b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt @@ -16,7 +16,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/pa @Suppress("unused") val `Permanent repeat` by creatingBytecodePatch( - description = "Adds an option to always repeat even if the playlist ends or another track is played." + description = "Adds an option to always repeat even if the playlist ends or another track is played.", ) { dependsOn( sharedExtensionPatch, @@ -27,8 +27,8 @@ val `Permanent repeat` by creatingBytecodePatch( compatibleWith( "com.google.android.apps.youtube.music"( "7.29.52", - "8.10.52" - ) + "8.10.52", + ), ) apply { @@ -38,7 +38,7 @@ val `Permanent repeat` by creatingBytecodePatch( SwitchPreference("revanced_music_play_permanent_repeat"), ) - val startIndex = repeatTrackMethod.instructionMatches.last().index // TODO + val startIndex = repeatTrackMethod.indices.last() // TODO val repeatIndex = startIndex + 1 repeatTrackMethod.apply { diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt index 8bb830ba8..e05772077 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt @@ -28,8 +28,8 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch( compatibleWith( "com.google.android.apps.youtube.music"( "7.29.52", - "8.10.52" - ) + "8.10.52", + ), ) apply { @@ -40,7 +40,7 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch( ) hideGetPremiumMethod.apply { - val insertIndex = hideGetPremiumMethod.instructionMatches.last().index // TODO + val insertIndex = hideGetPremiumMethod.indices.last() // TODO val setVisibilityInstruction = getInstruction(insertIndex) val getPremiumViewRegister = setVisibilityInstruction.registerC @@ -54,7 +54,7 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch( addInstruction( insertIndex + 1, "invoke-virtual {v$getPremiumViewRegister, v$visibilityRegister}, " + - "Landroid/view/View;->setVisibility(I)V", + "Landroid/view/View;->setVisibility(I)V", ) } @@ -68,7 +68,7 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch( return-object v0 :show nop - """ + """, ) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt index ddc3196ba..07384b71d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt @@ -1,15 +1,11 @@ package app.revanced.patches.shared.misc.fix.verticalscroll -import app.revanced.patcher.accessFlags -import app.revanced.patcher.gettingFirstMethodDeclaratively -import app.revanced.patcher.opcodes -import app.revanced.patcher.parameterTypes -import app.revanced.patcher.patch.BytecodePatchContext -import app.revanced.patcher.returnType +import app.revanced.patcher.* import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val BytecodePatchContext.canScrollVerticallyMethod by gettingFirstMethodDeclaratively { +internal val canScrollVerticallyMatch = firstMethodComposite { + definingClass("SwipeRefreshLayout;"::endsWith) accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returnType("Z") parameterTypes() @@ -19,5 +15,4 @@ internal val BytecodePatchContext.canScrollVerticallyMethod by gettingFirstMetho Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT, ) - custom { _, classDef -> classDef.endsWith("SwipeRefreshLayout;") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt index 3244ccb95..200c06d8c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt @@ -12,7 +12,7 @@ val verticalScrollPatch = bytecodePatch( apply { canScrollVerticallyMethod.let { it.method.apply { - val moveResultIndex = it.instructionMatches.last().index + val moveResultIndex = it.indices.last() val moveResultRegister = getInstruction(moveResultIndex).registerA val insertIndex = moveResultIndex + 1 diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt index 33118b474..57aca0fb5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt @@ -20,7 +20,7 @@ val `Fix old versions` by creatingBytecodePatch( // Remove the live query parameters from the path when it's specified via a @METHOD annotation. for (liveQueryParameter in liveQueryParameters) { httpPathParserMethod.addInstructions( - httpPathParserMethod.instructionMatches.last().index + 1, + httpPathParserMethod.indices.last() + 1, """ # urlPath = urlPath.replace(liveQueryParameter, "") const-string p1, "$liveQueryParameter" diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt index 15d916459..252223536 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt @@ -47,7 +47,7 @@ val `Unlock downloads` by creatingBytecodePatch( const/4 v${checkMediaTypeInstruction.registerB}, 0x2 # GIF if-eq v${checkMediaTypeInstruction.registerA}, v${checkMediaTypeInstruction.registerB}, :video """, - ExternalLabel("video", getInstruction(it.instructionMatches.last().index)), + ExternalLabel("video", getInstruction(it.indices.last())), ) // Remove media.isDownloadable check. diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index 1f12a37a6..23e284848 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -42,7 +42,7 @@ val `Remove viewer discretion dialog` by creatingBytecodePatch( createDialogMethod.let { it.method.apply { - val showDialogIndex = it.instructionMatches.last().index // TODO + val showDialogIndex = it.indices.last() // TODO val dialogRegister = getInstruction(showDialogIndex).registerC replaceInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index 3bb74bcd7..5851bd1a2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -40,12 +40,12 @@ val enableSeekbarTappingPatch = bytecodePatch( listOf( getReference(it.instructionMatches.first().index), - getReference(it.instructionMatches.last().index), + getReference(it.indices.last()), ) } seekbarTappingMethod.let { - val insertIndex = it.instructionMatches.last().index + 1 + val insertIndex = it.indices.last() + 1 it.method.apply { val thisInstanceRegister = getInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index cb77a6527..cf38e1c41 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -75,7 +75,7 @@ val enableSlideToSeekPatch = bytecodePatch( if (is_19_17_or_greater) { disableFastForwardGestureMethod.let { it.method.apply { - val targetIndex = it.instructionMatches.last().index + val targetIndex = it.indices.last() val targetRegister = getInstruction(targetIndex).registerA addInstructions( @@ -90,7 +90,7 @@ val enableSlideToSeekPatch = bytecodePatch( } else { disableFastForwardLegacyMethod.let { it.method.apply { - val insertIndex = it.instructionMatches.last().index + 1 + val insertIndex = it.indices.last() + 1 val targetRegister = getInstruction(insertIndex).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt index 1ec066860..5952693bb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt @@ -136,7 +136,7 @@ val `Swipe controls` by creatingBytecodePatch( if (is_19_43_or_greater && !is_20_34_or_greater) { swipeChangeVideoMethod.let { it.method.insertLiteralOverride( - it.instructionMatches.last().index, // TODO + it.indices.last(), // TODO "$EXTENSION_CLASS_DESCRIPTOR->allowSwipeChangeVideo(Z)Z", ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt index 0879eea2c..f713731a3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt @@ -138,7 +138,7 @@ val `Hide player overlay buttons` by creatingBytecodePatch( inflateControlsGroupLayoutStubMethodMatch.let { it.method.apply { - val insertIndex = it.instructionMatches.last().index + 1 + val insertIndex = it.indices.last() + 1 val freeRegister = findFreeRegister(insertIndex) addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt index dd7bc0f21..75e4109d5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/formfactor/ChangeFormFactorPatch.kt @@ -64,7 +64,7 @@ val `Change form factor` by creatingBytecodePatch( createPlayerRequestBodyWithModelFingerprint.let { it.method.apply { - val index = it.instructionMatches.last().index + val index = it.indices.last() val register = getInstruction(index).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndScreenCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndScreenCardsPatch.kt index 479ea26a7..33a9270fe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndScreenCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndScreenCardsPatch.kt @@ -75,7 +75,7 @@ val `Hide end screen cards` by creatingBytecodePatch( layoutVideoMethod, ).forEach { fingerprint -> fingerprint.method.apply { - val insertIndex = fingerprint.instructionMatches.last().index + 1 // TODO + val insertIndex = fingerprint.indices.last() + 1 // TODO val viewRegister = getInstruction(insertIndex - 1).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt index e8593c634..9686fbee9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreensuggestion/HideEndScreenSuggestedVideoPatch.kt @@ -45,7 +45,7 @@ val `Hide end screen suggested video` by creatingBytecodePatch( ) removeOnLayoutChangeListenerMethod.let { - val endScreenMethod = navigate(it.originalMethod).to(it.instructionMatches.last().index).stop() // TODO + val endScreenMethod = navigate(it.originalMethod).to(it.indices.last()).stop() // TODO endScreenMethod.apply { val autoNavStatusMethodName = autoNavStatusMethod.match( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 27db61f1c..6fe144116 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -289,7 +289,7 @@ val `Hide layout components` by creatingBytecodePatch( (if (is_20_26_or_greater) hideShowMoreButtonMethod else hideShowMoreLegacyButtonMethod).let { it.method.apply { - val moveRegisterIndex = it.instructionMatches.last().index + val moveRegisterIndex = it.indices.last() val viewRegister = getInstruction(moveRegisterIndex).registerA val insertIndex = moveRegisterIndex + 1 @@ -306,7 +306,7 @@ val `Hide layout components` by creatingBytecodePatch( // region crowdfunding box crowdfundingBoxMethod.let { it.method.apply { - val insertIndex = it.instructionMatches.last().index + val insertIndex = it.indices.last() val objectRegister = getInstruction(insertIndex).registerA addInstruction( @@ -323,7 +323,7 @@ val `Hide layout components` by creatingBytecodePatch( albumCardsMethod.let { it.method.apply { - val checkCastAnchorIndex = it.instructionMatches.last().index + val checkCastAnchorIndex = it.indices.last() val insertIndex = checkCastAnchorIndex + 1 val register = getInstruction(checkCastAnchorIndex).registerA @@ -341,7 +341,7 @@ val `Hide layout components` by creatingBytecodePatch( showFloatingMicrophoneButtonMethod.let { it.method.apply { - val index = it.instructionMatches.last().index + val index = it.indices.last() val register = getInstruction(index).registerA addInstructions( @@ -422,7 +422,7 @@ val `Hide layout components` by creatingBytecodePatch( hookRegisterOffset: Int = 0, instructions: (Int) -> String, ) = method.apply { - val endIndex = instructionMatches.last().index + val endIndex = indices.last() val insertIndex = endIndex + insertIndexOffset val register = getInstruction(endIndex + hookRegisterOffset).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt index 85573f4aa..da3331628 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt @@ -78,7 +78,7 @@ val `Hide info cards` by creatingBytecodePatch( // Edit: This old non litho code may be obsolete and no longer used by any supported versions. infocardsMethodCallMethod.let { - val invokeInterfaceIndex = it.instructionMatches.last().index + val invokeInterfaceIndex = it.indices.last() it.method.apply { val register = implementation!!.registerCount - 1 diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index b834a10a4..0fe8993b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -46,7 +46,7 @@ val `Disable rolling number animations` by creatingBytecodePatch( // which prevents the animations from appearing. rollingNumberTextViewAnimationUpdateMethod.let { val blockStartIndex = it.instructionMatches.first().index - val blockEndIndex = it.instructionMatches.last().index + 1 + val blockEndIndex = it.indices.last() + 1 it.method.apply { val freeRegister = getInstruction(blockStartIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 1af8ca258..3627d0c7b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -210,7 +210,7 @@ val `Hide Shorts componentsby creatingBytecodePatch( setPivotBarVisibilityParentMethod.originalClassDef, ).let { result -> result.method.apply { - val insertIndex = result.instructionMatches.last().index + val insertIndex = result.indices.last() val viewRegister = getInstruction(insertIndex - 1).registerA addInstruction( insertIndex, @@ -239,7 +239,7 @@ val `Hide Shorts componentsby creatingBytecodePatch( // Hide the bottom bar container of the Shorts player. shortsBottomBarContainerMethod.let { it.method.apply { - val targetIndex = it.instructionMatches.last().index + val targetIndex = it.indices.last() val heightRegister = getInstruction(targetIndex).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt index 9e51b7629..d2b225f1a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt @@ -249,7 +249,7 @@ val Miniplayer by creatingBytecodePatch( // region Legacy tablet miniplayer hooks. miniplayerOverrideMethod.let { - val appNameStringIndex = it.instructionMatches.last().index + val appNameStringIndex = it.indices.last() navigate(it.originalMethod).to(appNameStringIndex).stop().apply { findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride( @@ -260,7 +260,7 @@ val Miniplayer by creatingBytecodePatch( } miniplayerResponseModelSizeCheckMethod.let { - it.method.insertLegacyTabletMiniplayerOverride(it.instructionMatches.last().index) + it.method.insertLegacyTabletMiniplayerOverride(it.indices.last()) } } @@ -421,7 +421,7 @@ val Miniplayer by creatingBytecodePatch( fingerprint.match( miniplayerModernViewParentMethod.classDef, ).method.apply { - val index = fingerprint.instructionMatches.last().index + val index = fingerprint.indices.last() val register = getInstruction(index).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt index dda4d04de..2cc062dc9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/fullscreen/OpenVideosFullscreenHookPatch.kt @@ -36,13 +36,13 @@ internal val openVideosFullscreenHookPatch = bytecodePatch { // Shorts fullscreen regular player does not use fullscreen // if the player is minimized and it must be forced using other conditional check. it.method.insertLiteralOverride( - it.instructionMatches.last().index, + it.indices.last(), false, ) } } else { fingerprint = openVideosFullscreenPortraitLegacyMethod - insertIndex = fingerprint.instructionMatches.last().index + insertIndex = fingerprint.indices.last() } fingerprint.let { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt index a842deecb..c7c37f949 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt @@ -43,7 +43,7 @@ val `Custom player overlay opacity` by creatingBytecodePatch( createPlayerOverviewMethod.let { it.method.apply { - val viewRegisterIndex = it.instructionMatches.last().index + val viewRegisterIndex = it.indices.last() val viewRegister = getInstruction(viewRegisterIndex).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 095d7688a..4460c13cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -222,7 +222,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch( rollingNumberSetterMethod.apply { val insertIndex = 1 - val dislikesIndex = rollingNumberSetterMethod.instructionMatches.last().index + val dislikesIndex = rollingNumberSetterMethod.indices.last() val charSequenceInstanceRegister = getInstruction(0).registerA val charSequenceFieldReference = @@ -248,7 +248,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch( rollingNumberMeasureAnimatedTextMethod.let { // Additional check to verify the opcodes are at the start of the method if (it.instructionMatches.first().index != 0) throw PatchException("Unexpected opcode location") - val endIndex = it.instructionMatches.last().index + val endIndex = it.indices.last() it.method.apply { val measuredTextWidthRegister = getInstruction(endIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt index 61cea61e3..7a4943d9c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt @@ -49,7 +49,7 @@ val seekbarColorPatch = bytecodePatch( playerSeekbarColorMethod.let { it.method.apply { - addColorChangeInstructions(it.instructionMatches.last().index) + addColorChangeInstructions(it.indices.last()) addColorChangeInstructions(it.instructionMatches.first().index) } } @@ -82,7 +82,7 @@ val seekbarColorPatch = bytecodePatch( handleBarColorFingerprints += playerSeekbarHandle2ColorMethod } handleBarColorFingerprints.forEach { - it.method.addColorChangeInstructions(it.instructionMatches.last().index) + it.method.addColorChangeInstructions(it.indices.last()) } // If hiding feed seekbar thumbnails, then turn off the cairo gradient @@ -125,7 +125,7 @@ val seekbarColorPatch = bytecodePatch( playerFingerprint.let { it.method.apply { - val index = it.instructionMatches.last().index + val index = it.indices.last() val register = getInstruction(index).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt index 17260d099..4daca3918 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt @@ -76,7 +76,7 @@ val `Shorts autoplay` by creatingBytecodePatch( reelEnumClass = it.originalClassDef.type it.method.addInstructions( - it.instructionMatches.last().index, + it.indices.last(), """ # Pass the first enum value to extension. # Any enum value of this type will work. diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index 0b0c0c9e0..d88a6548a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -83,7 +83,7 @@ val `Spoof app version` by creatingBytecodePatch( toolBarButtonMethod.apply { val imageResourceIndex = instructionMatches[2].index val register = method.getInstruction(imageResourceIndex).registerA - val jumpIndex = instructionMatches.last().index + 1 + val jumpIndex = indices.last() + 1 method.addInstructionsWithLabels( imageResourceIndex + 1, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt index e95703416..8df94702d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt @@ -18,7 +18,7 @@ internal val fixBackToExitGesturePatch = bytecodePatch( apply { recyclerViewTopScrollingMethod.let { it.method.addInstructionsAtControlFlowLabel( - it.instructionMatches.last().index + 1, + it.indices.last() + 1, "invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->onTopView()V", ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/AccountCredentialsInvalidTextPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/AccountCredentialsInvalidTextPatch.kt index e92115bd0..f6f1d9b28 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/AccountCredentialsInvalidTextPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/gms/AccountCredentialsInvalidTextPatch.kt @@ -34,7 +34,7 @@ internal val accountCredentialsInvalidTextPatch = bytecodePatch { loadingFrameLayoutControllerMethod, ).forEach { fingerprint -> fingerprint.apply { - val index = instructionMatches.last().index + val index = indices.last() val register = method.getInstruction(index).registerA method.addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt index ad61757f7..a698e6aa2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt @@ -93,7 +93,7 @@ val lithoFilterPatch = bytecodePatch( protobufBufferReferenceMethod.let { // Hook the buffer after the call to jniDecode(). it.method.addInstruction( - it.instructionMatches.last().index + 1, + it.indices.last() + 1, "invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer([B)V", ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/loopvideo/LoopVideoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/loopvideo/LoopVideoPatch.kt index a50fd526b..7a44dadbd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/loopvideo/LoopVideoPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/loopvideo/LoopVideoPatch.kt @@ -52,7 +52,7 @@ val `Loop video` by creatingBytecodePatch( invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->shouldLoopVideo()Z move-result v0 if-eqz v0, :do_not_loop - invoke-virtual { p0 }, ${videoStartPlaybackFingerprint.method} + invoke-virtual { p0 }, $videoStartPlaybackMethod return-void :do_not_loop nop diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt index 8ec6c148f..b3f907882 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt @@ -140,7 +140,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig // so this works regardless which layout is used. actionBarSearchResultsMethod.let { it.method.apply { - val instructionIndex = it.instructionMatches.last().index + val instructionIndex = it.indices.last() val viewRegister = getInstruction(instructionIndex).registerC addInstruction( @@ -155,7 +155,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig toolbarLayoutMethod.let { it.method.apply { - val index = it.instructionMatches.last().index + val index = it.indices.last() val register = getInstruction(index).registerA addInstruction( @@ -218,7 +218,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig .instructionMatches.last().getInstruction().reference setEnumMapMethod.apply { - val setEnumIntegerIndex = setEnumMapMethod.instructionMatches.last().index + val setEnumIntegerIndex = setEnumMapMethod.indices.last() val enumMapRegister = getInstruction(setEnumIntegerIndex).registerC val insertIndex = setEnumIntegerIndex + 1 val freeRegister = findFreeRegister(insertIndex, enumMapRegister) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt index 16b19b9df..c54e80a50 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt @@ -248,7 +248,7 @@ val playerControlsPatch = bytecodePatch( it.method.apply { inflateBottomControlMethod = this - val inflateReturnObjectIndex = it.instructionMatches.last().index + val inflateReturnObjectIndex = it.indices.last() inflateBottomControlRegister = getInstruction(inflateReturnObjectIndex).registerA inflateBottomControlInsertIndex = inflateReturnObjectIndex + 1 } @@ -258,7 +258,7 @@ val playerControlsPatch = bytecodePatch( it.method.apply { inflateTopControlMethod = this - val inflateReturnObjectIndex = it.instructionMatches.last().index + val inflateReturnObjectIndex = it.indices.last() inflateTopControlRegister = getInstruction(inflateReturnObjectIndex).registerA inflateTopControlInsertIndex = inflateReturnObjectIndex + 1 } @@ -272,7 +272,7 @@ val playerControlsPatch = bytecodePatch( // when seeking and other situations. overlayViewInflateMethod.let { it.method.apply { - val index = it.instructionMatches.last().index + val index = it.indices.last() val register = getInstruction(index).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt index f3b6ab43e..50696f282 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt @@ -36,7 +36,7 @@ val playerTypeHookPatch = bytecodePatch( reelWatchPagerMethod.let { it.method.apply { - val index = it.instructionMatches.last().index + val index = it.indices.last() val register = getInstruction(index).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/AdvancedVideoQualityMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/AdvancedVideoQualityMenuPatch.kt index 56c465267..365f7bdc0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/AdvancedVideoQualityMenuPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/AdvancedVideoQualityMenuPatch.kt @@ -62,7 +62,7 @@ internal val advancedVideoQualityMenuPatch = bytecodePatch { // and for the Shorts quality flyout on newer app versions. videoQualityMenuViewInflateMethod.let { it.method.apply { - val checkCastIndex = it.instructionMatches.last().index + val checkCastIndex = it.indices.last() val listViewRegister = getInstruction(checkCastIndex).registerA addInstruction(