mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-28 21:21:02 +00:00
indices replacement and more refactor
This commit is contained in:
@@ -13,7 +13,7 @@ val `Remove file size limit` by creatingBytecodePatch(
|
||||
|
||||
apply {
|
||||
onReadyMethod.apply {
|
||||
val cmpIndex = onReadyMethod.instructionMatches.first().index + 1 // TODO
|
||||
val cmpIndex = onReadyMethod.indices.first() + 1 // TODO
|
||||
val cmpResultRegister = getInstruction<ThreeRegisterInstruction>(cmpIndex).registerA
|
||||
|
||||
replaceInstruction(cmpIndex, "const/4 v$cmpResultRegister, 0x0")
|
||||
|
||||
@@ -69,7 +69,7 @@ val overrideFeatureFlagsPatch = bytecodePatch(
|
||||
// This is equivalent to
|
||||
// String forcedValue = getValueOverride(feature)
|
||||
// if (forcedValue != null) return forcedValue
|
||||
val getFeatureIndex = getFeatureValueMethod.instructionMatches.first().index
|
||||
val getFeatureIndex = getFeatureValueMethod.indices.first()
|
||||
getFeatureValueMethod.addInstructionsWithLabels(
|
||||
getFeatureIndex,
|
||||
"""
|
||||
|
||||
@@ -24,7 +24,7 @@ val filterTimelineObjectsPatch = bytecodePatch(
|
||||
dependsOn(sharedExtensionPatch)
|
||||
|
||||
apply {
|
||||
val filterInsertIndex = timelineFilterExtensionMethod.instructionMatches.first().index
|
||||
val filterInsertIndex = timelineFilterExtensionMethod.indices.first()
|
||||
|
||||
timelineFilterExtensionMethod.apply {
|
||||
val addInstruction = getInstruction<BuilderInstruction35c>(filterInsertIndex + 1)
|
||||
|
||||
@@ -20,7 +20,7 @@ val `Unlock downloads` by creatingBytecodePatch(
|
||||
|
||||
// Allow downloads for non-premium users.
|
||||
showDownloadVideoUpsellBottomSheetMethod.patch {
|
||||
val checkIndex = instructionMatches.first().index
|
||||
val checkIndex = indices.first()
|
||||
val register = method.getInstruction<OneRegisterInstruction>(checkIndex).registerA
|
||||
|
||||
checkIndex to register
|
||||
@@ -37,7 +37,7 @@ val `Unlock downloads` by creatingBytecodePatch(
|
||||
// Make GIFs downloadable.
|
||||
buildMediaOptionsSheetMethod.let {
|
||||
it.method.apply {
|
||||
val checkMediaTypeIndex = it.instructionMatches.first().index
|
||||
val checkMediaTypeIndex = it.indices.first()
|
||||
val checkMediaTypeInstruction = getInstruction<TwoRegisterInstruction>(checkMediaTypeIndex)
|
||||
|
||||
// Treat GIFs as videos.
|
||||
|
||||
@@ -40,7 +40,7 @@ val hideGetPremiumPatch = bytecodePatch(
|
||||
)
|
||||
|
||||
getPremiumViewMethod.apply {
|
||||
val startIndex = getPremiumViewMethod.instructionMatches.first().index
|
||||
val startIndex = getPremiumViewMethod.indices.first()
|
||||
val measuredWidthRegister = getInstruction<TwoRegisterInstruction>(startIndex).registerA
|
||||
val measuredHeightInstruction = getInstruction<TwoRegisterInstruction>(startIndex + 1)
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ val enableSeekbarTappingPatch = bytecodePatch(
|
||||
.reference as MethodReference
|
||||
|
||||
listOf(
|
||||
getReference(it.instructionMatches.first().index),
|
||||
getReference(it.indices.first()),
|
||||
getReference(it.indices.last()),
|
||||
)
|
||||
}
|
||||
@@ -53,7 +53,7 @@ val enableSeekbarTappingPatch = bytecodePatch(
|
||||
).registerC
|
||||
|
||||
val xAxisRegister = this.getInstruction<FiveRegisterInstruction>(
|
||||
it.instructionMatches[2].index,
|
||||
it.indices[2],
|
||||
).registerD
|
||||
|
||||
val freeRegister = findFreeRegister(
|
||||
|
||||
@@ -42,7 +42,7 @@ val enableSlideToSeekPatch = bytecodePatch(
|
||||
|
||||
// Restore the behaviour to slide to seek.
|
||||
|
||||
val checkIndex = slideToSeekMethod.instructionMatches.first().index
|
||||
val checkIndex = slideToSeekMethod.indices.first()
|
||||
val checkReference = slideToSeekMethod.getInstruction(checkIndex)
|
||||
.getReference<MethodReference>()!!
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ val hideSeekbarPatch = bytecodePatch(
|
||||
if (is_20_28_or_greater) {
|
||||
fullscreenLargeSeekbarFeatureFlagMethodMatch.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useFullscreenLargeSeekbar(Z)Z",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation
|
||||
|
||||
import app.revanced.patcher.accessFlags
|
||||
import app.revanced.patcher.after
|
||||
import app.revanced.patcher.firstMethodComposite
|
||||
import app.revanced.patcher.gettingFirstMethodDeclaratively
|
||||
import app.revanced.patcher.instructions
|
||||
import app.revanced.patcher.invoke
|
||||
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
|
||||
|
||||
@@ -20,7 +12,7 @@ internal val addCreateButtonViewMethodMatch = firstMethodComposite {
|
||||
)
|
||||
}
|
||||
|
||||
internal val BytecodePatchContext.createPivotBarMethod by gettingFirstMethodDeclaratively {
|
||||
internal val createPivotBarMethodMatch = firstMethodComposite {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameterTypes(
|
||||
"Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;",
|
||||
@@ -28,12 +20,12 @@ internal val BytecodePatchContext.createPivotBarMethod by gettingFirstMethodDecl
|
||||
"Ljava/lang/CharSequence;",
|
||||
)
|
||||
instructions(
|
||||
methodCall(definingClass = "Landroid/widget/TextView;", name = "setText"),
|
||||
method { name == "setText" && definingClass == "Landroid/widget/TextView;" },
|
||||
Opcode.RETURN_VOID(),
|
||||
)
|
||||
}
|
||||
|
||||
internal val BytecodePatchContext.animatedNavigationTabsFeatureFlagMethod by gettingFirstMethodDeclaratively {
|
||||
internal val animatedNavigationTabsFeatureFlagMethodMatch = firstMethodComposite {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returnType("Z")
|
||||
instructions(
|
||||
@@ -41,7 +33,7 @@ internal val BytecodePatchContext.animatedNavigationTabsFeatureFlagMethod by get
|
||||
)
|
||||
}
|
||||
|
||||
internal val BytecodePatchContext.translucentNavigationStatusBarFeatureFlagMethod by gettingFirstMethodDeclaratively {
|
||||
internal val translucentNavigationStatusBarFeatureFlagMethodMatch = firstMethodComposite {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returnType("Z")
|
||||
instructions(
|
||||
@@ -52,7 +44,7 @@ internal val BytecodePatchContext.translucentNavigationStatusBarFeatureFlagMetho
|
||||
/**
|
||||
* YouTube nav buttons.
|
||||
*/
|
||||
internal val BytecodePatchContext.translucentNavigationButtonsFeatureFlagMethod by gettingFirstMethodDeclaratively {
|
||||
internal val translucentNavigationButtonsFeatureFlagMethodMatch = firstMethodComposite {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returnType("V")
|
||||
instructions(
|
||||
@@ -63,7 +55,7 @@ internal val BytecodePatchContext.translucentNavigationButtonsFeatureFlagMethod
|
||||
/**
|
||||
* Device on screen back/home/recent buttons.
|
||||
*/
|
||||
internal val BytecodePatchContext.translucentNavigationButtonsSystemFeatureFlagMethod by gettingFirstMethodDeclaratively {
|
||||
internal val translucentNavigationButtonsSystemFeatureFlagMethodMatch = firstMethodComposite {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returnType("Z")
|
||||
instructions(
|
||||
|
||||
@@ -97,9 +97,9 @@ val `Navigation buttons` by creatingBytecodePatch(
|
||||
}
|
||||
|
||||
// Hide navigation button labels.
|
||||
createPivotBarMethod.let {
|
||||
createPivotBarMethodMatch.let {
|
||||
it.method.apply {
|
||||
val setTextIndex = it.instructionMatches.first().index
|
||||
val setTextIndex = it.indices.first()
|
||||
val targetRegister = getInstruction<FiveRegisterInstruction>(setTextIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
@@ -115,32 +115,32 @@ val `Navigation buttons` by creatingBytecodePatch(
|
||||
|
||||
// Force on/off translucent effect on status bar and navigation buttons.
|
||||
if (is_19_25_or_greater) {
|
||||
translucentNavigationStatusBarFeatureFlagMethod.let {
|
||||
translucentNavigationStatusBarFeatureFlagMethodMatch.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationStatusBar(Z)Z",
|
||||
)
|
||||
}
|
||||
|
||||
translucentNavigationButtonsFeatureFlagMethod.let {
|
||||
translucentNavigationButtonsFeatureFlagMethodMatch.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationButtons(Z)Z",
|
||||
)
|
||||
}
|
||||
|
||||
translucentNavigationButtonsSystemFeatureFlagMethod.let {
|
||||
translucentNavigationButtonsSystemFeatureFlagMethodMatch.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationButtons(Z)Z",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (is_20_15_or_greater) {
|
||||
animatedNavigationTabsFeatureFlagMethod.let {
|
||||
animatedNavigationTabsFeatureFlagMethodMatch.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useAnimatedNavigationButtons(Z)Z",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ val `Hide layout components` by creatingBytecodePatch(
|
||||
// region Mix playlists
|
||||
|
||||
parseElementFromBufferMethod.apply {
|
||||
val startIndex = parseElementFromBufferMethod.instructionMatches.first().index
|
||||
val startIndex = parseElementFromBufferMethod.indices.first()
|
||||
val insertIndex = startIndex + 1
|
||||
|
||||
val byteArrayParameter = "p3"
|
||||
|
||||
@@ -46,7 +46,7 @@ val `Disable rolling number animations` by creatingBytecodePatch(
|
||||
// Animations are disabled by preventing an Image from being applied to the text span,
|
||||
// which prevents the animations from appearing.
|
||||
rollingNumberTextViewAnimationUpdateMethod.let {
|
||||
val blockStartIndex = it.instructionMatches.first().index
|
||||
val blockStartIndex = it.indices.first()
|
||||
val blockEndIndex = it.indices.last() + 1
|
||||
it.method.apply {
|
||||
val freeRegister = getInstruction<OneRegisterInstruction>(blockStartIndex).registerA
|
||||
|
||||
@@ -326,7 +326,7 @@ val Miniplayer by creatingBytecodePatch(
|
||||
// Override a minimum size constant.
|
||||
miniplayerMinimumSizeMethod.let {
|
||||
it.method.apply {
|
||||
val index = it.instructionMatches[1].index
|
||||
val index = it.indices[1]
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
// Smaller sizes can be used, but the miniplayer will always start in size 170 if set any smaller.
|
||||
|
||||
@@ -28,7 +28,7 @@ internal val openVideosFullscreenHookPatch = bytecodePatch {
|
||||
|
||||
if (is_19_46_or_greater) {
|
||||
fingerprint = openVideosFullscreenPortraitMethod
|
||||
insertIndex = fingerprint.instructionMatches.first().index
|
||||
insertIndex = fingerprint.indices.first()
|
||||
|
||||
openVideosFullscreenPortraitMethod.let {
|
||||
// Remove A/B feature call that forces what this patch already does.
|
||||
|
||||
@@ -248,7 +248,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch(
|
||||
// Modify the measure text calculation to include the left drawable separator if needed.
|
||||
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")
|
||||
if (it.indices.first() != 0) throw PatchException("Unexpected opcode location")
|
||||
val endIndex = it.indices.last()
|
||||
|
||||
it.method.apply {
|
||||
@@ -269,7 +269,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch(
|
||||
rollingNumberMeasureStaticLabelMethod.match(
|
||||
rollingNumberMeasureStaticLabelParentMethod.immutableClassDef,
|
||||
).let {
|
||||
val measureTextIndex = it.instructionMatches.first().index + 1
|
||||
val measureTextIndex = it.indices.first() + 1
|
||||
it.method.apply {
|
||||
val freeRegister = getInstruction<TwoRegisterInstruction>(0).registerA
|
||||
|
||||
|
||||
@@ -50,16 +50,16 @@ val seekbarColorPatch = bytecodePatch(
|
||||
playerSeekbarColorMethod.let {
|
||||
it.method.apply {
|
||||
addColorChangeInstructions(it.indices.last())
|
||||
addColorChangeInstructions(it.instructionMatches.first().index)
|
||||
addColorChangeInstructions(it.indices.first())
|
||||
}
|
||||
}
|
||||
|
||||
shortsSeekbarColorMethod.let {
|
||||
it.method.addColorChangeInstructions(it.instructionMatches.first().index)
|
||||
it.method.addColorChangeInstructions(it.indices.first())
|
||||
}
|
||||
|
||||
setSeekbarClickedColorMethod.immutableMethod.let {
|
||||
val setColorMethodIndex = setSeekbarClickedColorMethod.instructionMatches.first().index + 1
|
||||
val setColorMethodIndex = setSeekbarClickedColorMethod.indices.first() + 1
|
||||
|
||||
navigate(it).to(setColorMethodIndex).stop().apply {
|
||||
val colorRegister = getInstruction<TwoRegisterInstruction>(0).registerA
|
||||
@@ -91,7 +91,7 @@ val seekbarColorPatch = bytecodePatch(
|
||||
if (is_19_34_or_greater) {
|
||||
watchHistoryMenuUseProgressDrawableMethod.let {
|
||||
it.method.apply {
|
||||
val index = it.instructionMatches[1].index
|
||||
val index = it.indices[1]
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstructions(
|
||||
|
||||
@@ -82,7 +82,7 @@ val `Spoof app version` by creatingBytecodePatch(
|
||||
* toolbar when the enum name is UNKNOWN.
|
||||
*/
|
||||
toolBarButtonMethod.apply {
|
||||
val imageResourceIndex = instructionMatches[2].index
|
||||
val imageResourceIndex = indices[2]
|
||||
val register = method.getInstruction<OneRegisterInstruction>(imageResourceIndex).registerA
|
||||
val jumpIndex = indices.last() + 1
|
||||
|
||||
@@ -94,7 +94,7 @@ val `Spoof app version` by creatingBytecodePatch(
|
||||
}
|
||||
|
||||
spoofAppVersionMethod.apply {
|
||||
val index = instructionMatches.first().index
|
||||
val index = indices.first()
|
||||
val register = method.getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
method.addInstructions(
|
||||
|
||||
@@ -103,7 +103,7 @@ val `Remove background playback restrictions` by creatingBytecodePatch(
|
||||
if (is_19_34_or_greater) {
|
||||
pipInputConsumerFeatureFlagMethod.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ val lithoFilterPatch = bytecodePatch(
|
||||
// 20.22 the flag is still enabled in one location, but what it does is not known.
|
||||
// Disable it anyway.
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
it.indices.first(),
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ val playerControlsOverlayVisibilityPatch = bytecodePatch {
|
||||
apply {
|
||||
playerControlsVisibilityEntityModelMethod.let {
|
||||
it.method.apply {
|
||||
val startIndex = it.instructionMatches.first().index
|
||||
val startIndex = it.indices.first()
|
||||
val iGetReference = getInstruction<ReferenceInstruction>(startIndex).reference
|
||||
val staticReference = getInstruction<ReferenceInstruction>(startIndex + 1).reference
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ val recyclerViewTreeHookPatch = bytecodePatch {
|
||||
|
||||
apply {
|
||||
recyclerViewTreeObserverMethod.apply {
|
||||
val insertIndex = recyclerViewTreeObserverMethod.instructionMatches.first().index + 1
|
||||
val insertIndex = recyclerViewTreeObserverMethod.indices.first() + 1
|
||||
val recyclerViewParameter = 2
|
||||
|
||||
addRecyclerViewTreeHook = { classDescriptor ->
|
||||
|
||||
@@ -172,7 +172,7 @@ internal val customPlaybackSpeedPatch = bytecodePatch(
|
||||
if (is_19_47_or_greater) {
|
||||
customTapAndHoldMethodMatch.let {
|
||||
it.method.apply {
|
||||
val index = it.instructionMatches.first().index
|
||||
val index = it.indices.first()
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstructions(
|
||||
|
||||
Reference in New Issue
Block a user