fix(YouTube): Combine multiple seekbar patches into a single patch (#4705)

This commit is contained in:
LisoUseInAIKyrios 2025-04-01 20:57:03 +02:00 committed by GitHub
parent 899c2fe228
commit 503b7eb8d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 107 additions and 108 deletions

View File

@ -1096,6 +1096,14 @@ public final class app/revanced/patches/youtube/interaction/seekbar/EnableSlideT
public static final fun getEnableSlideToSeekPatch ()Lapp/revanced/patcher/patch/BytecodePatch; public static final fun getEnableSlideToSeekPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
} }
public final class app/revanced/patches/youtube/interaction/seekbar/HideSeekbarPatchKt {
public static final fun getHideSeekbarPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/youtube/interaction/seekbar/SeekbarPatchKt {
public static final fun getSeekbarPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatchKt { public final class app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatchKt {
public static final fun getSeekbarThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; public static final fun getSeekbarThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
} }

View File

@ -11,8 +11,10 @@ import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch import app.revanced.patches.youtube.misc.settings.settingsPatch
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/DisablePreciseSeekingGesturePatch;"
val disablePreciseSeekingGesturePatch = bytecodePatch( val disablePreciseSeekingGesturePatch = bytecodePatch(
name = "Disable precise seeking gesture",
description = "Adds an option to disable precise seeking when swiping up on the seekbar.", description = "Adds an option to disable precise seeking when swiping up on the seekbar.",
) { ) {
dependsOn( dependsOn(
@ -21,25 +23,12 @@ val disablePreciseSeekingGesturePatch = bytecodePatch(
addResourcesPatch, addResourcesPatch,
) )
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
),
)
execute { execute {
addResources("youtube", "interaction.seekbar.disablePreciseSeekingGesturePatch") addResources("youtube", "interaction.seekbar.disablePreciseSeekingGesturePatch")
PreferenceScreen.SEEKBAR.addPreferences( PreferenceScreen.SEEKBAR.addPreferences(
SwitchPreference("revanced_disable_precise_seeking_gesture"), SwitchPreference("revanced_disable_precise_seeking_gesture"),
) )
val extensionMethodDescriptor =
"Lapp/revanced/extension/youtube/patches/DisablePreciseSeekingGesturePatch;"
allowSwipingUpGestureFingerprint.match( allowSwipingUpGestureFingerprint.match(
swipingUpGestureParentFingerprint.originalClassDef, swipingUpGestureParentFingerprint.originalClassDef,
@ -47,7 +36,7 @@ val disablePreciseSeekingGesturePatch = bytecodePatch(
addInstructionsWithLabels( addInstructionsWithLabels(
0, 0,
""" """
invoke-static { }, $extensionMethodDescriptor->isGestureDisabled()Z invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->isGestureDisabled()Z
move-result v0 move-result v0
if-eqz v0, :disabled if-eqz v0, :disabled
return-void return-void
@ -62,7 +51,7 @@ val disablePreciseSeekingGesturePatch = bytecodePatch(
addInstructionsWithLabels( addInstructionsWithLabels(
0, 0,
""" """
invoke-static { }, $extensionMethodDescriptor->isGestureDisabled()Z invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->isGestureDisabled()Z
move-result v0 move-result v0
if-eqz v0, :disabled if-eqz v0, :disabled
const/4 v0, 0x0 const/4 v0, 0x0

View File

@ -15,7 +15,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference
val enableSeekbarTappingPatch = bytecodePatch( val enableSeekbarTappingPatch = bytecodePatch(
name = "Enable tap to seek",
description = "Adds an option to enable tap to seek on the seekbar of the video player.", description = "Adds an option to enable tap to seek on the seekbar of the video player.",
) { ) {
dependsOn( dependsOn(
@ -24,17 +23,6 @@ val enableSeekbarTappingPatch = bytecodePatch(
addResourcesPatch, addResourcesPatch,
) )
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
),
)
execute { execute {
addResources("youtube", "interaction.seekbar.enableSeekbarTappingPatch") addResources("youtube", "interaction.seekbar.enableSeekbarTappingPatch")

View File

@ -18,11 +18,9 @@ import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal const val EXTENSION_METHOD_DESCRIPTOR = private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/SlideToSeekPatch;"
"Lapp/revanced/extension/youtube/patches/SlideToSeekPatch;->isSlideToSeekDisabled(Z)Z"
val enableSlideToSeekPatch = bytecodePatch( val enableSlideToSeekPatch = bytecodePatch(
name = "Enable slide to seek",
description = "Adds an option to enable slide to seek " + description = "Adds an option to enable slide to seek " +
"instead of playing at 2x speed when pressing and holding in the video player." "instead of playing at 2x speed when pressing and holding in the video player."
) { ) {
@ -33,17 +31,6 @@ val enableSlideToSeekPatch = bytecodePatch(
versionCheckPatch, versionCheckPatch,
) )
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
),
)
execute { execute {
addResources("youtube", "interaction.seekbar.enableSlideToSeekPatch") addResources("youtube", "interaction.seekbar.enableSlideToSeekPatch")
@ -59,6 +46,8 @@ val enableSlideToSeekPatch = bytecodePatch(
val checkReference = slideToSeekFingerprint.method.getInstruction(checkIndex) val checkReference = slideToSeekFingerprint.method.getInstruction(checkIndex)
.getReference<MethodReference>()!! .getReference<MethodReference>()!!
val extensionMethodDescriptor = "$EXTENSION_CLASS_DESCRIPTOR->isSlideToSeekDisabled(Z)Z"
// A/B check method was only called on this class. // A/B check method was only called on this class.
slideToSeekFingerprint.classDef.methods.forEach { method -> slideToSeekFingerprint.classDef.methods.forEach { method ->
method.findInstructionIndicesReversed { method.findInstructionIndicesReversed {
@ -70,7 +59,7 @@ val enableSlideToSeekPatch = bytecodePatch(
addInstructions( addInstructions(
index + 2, index + 2,
""" """
invoke-static { v$register }, $EXTENSION_METHOD_DESCRIPTOR invoke-static { v$register }, $extensionMethodDescriptor
move-result v$register move-result v$register
""", """,
) )
@ -95,7 +84,7 @@ val enableSlideToSeekPatch = bytecodePatch(
addInstructions( addInstructions(
targetIndex + 1, targetIndex + 1,
""" """
invoke-static { v$targetRegister }, $EXTENSION_METHOD_DESCRIPTOR invoke-static { v$targetRegister }, $extensionMethodDescriptor
move-result v$targetRegister move-result v$targetRegister
""", """,
) )
@ -109,7 +98,7 @@ val enableSlideToSeekPatch = bytecodePatch(
addInstructions( addInstructions(
insertIndex, insertIndex,
""" """
invoke-static { v$targetRegister }, $EXTENSION_METHOD_DESCRIPTOR invoke-static { v$targetRegister }, $extensionMethodDescriptor
move-result v$targetRegister move-result v$targetRegister
""", """,
) )

View File

@ -0,0 +1,46 @@
package app.revanced.patches.youtube.interaction.seekbar
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.layout.seekbar.seekbarColorPatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.patches.youtube.shared.seekbarFingerprint
import app.revanced.patches.youtube.shared.seekbarOnDrawFingerprint
val hideSeekbarPatch = bytecodePatch(
description = "Adds an option to hide the seekbar.",
) {
dependsOn(
sharedExtensionPatch,
settingsPatch,
seekbarColorPatch,
addResourcesPatch,
)
execute {
addResources("youtube", "layout.hide.seekbar.hideSeekbarPatch")
PreferenceScreen.SEEKBAR.addPreferences(
SwitchPreference("revanced_hide_seekbar"),
SwitchPreference("revanced_hide_seekbar_thumbnail"),
)
seekbarOnDrawFingerprint.match(seekbarFingerprint.originalClassDef).method.addInstructionsWithLabels(
0,
"""
const/4 v0, 0x0
invoke-static { }, Lapp/revanced/extension/youtube/patches/HideSeekbarPatch;->hideSeekbar()Z
move-result v0
if-eqz v0, :hide_seekbar
return-void
:hide_seekbar
nop
""",
)
}
}

View File

@ -0,0 +1,31 @@
package app.revanced.patches.youtube.interaction.seekbar
import app.revanced.patcher.patch.bytecodePatch
@Suppress("unused")
val seekbarPatch = bytecodePatch(
name = "Seekbar",
description = "Adds options to disable precise seeking when swiping up on the seekbar, " +
"slide to seek instead of playing at 2x speed when pressing and holding, " +
"tapping the player seekbar to seek, " +
"and hiding the video player seekbar."
) {
dependsOn(
disablePreciseSeekingGesturePatch,
enableSlideToSeekPatch,
enableSeekbarTappingPatch,
hideSeekbarPatch,
seekbarThumbnailsPatch
)
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
)
)
}

View File

@ -10,6 +10,7 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.layout.seekbar.fullscreenSeekbarThumbnailsFingerprint import app.revanced.patches.youtube.layout.seekbar.fullscreenSeekbarThumbnailsFingerprint
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater
import app.revanced.patches.youtube.misc.playservice.is_20_09_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.PreferenceScreen
@ -17,7 +18,6 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/SeekbarThumbnailsPatch;" "Lapp/revanced/extension/youtube/patches/SeekbarThumbnailsPatch;"
val seekbarThumbnailsPatch = bytecodePatch( val seekbarThumbnailsPatch = bytecodePatch(
name = "Seekbar thumbnails",
description = "Adds an option to use high quality fullscreen seekbar thumbnails. " + description = "Adds an option to use high quality fullscreen seekbar thumbnails. " +
"Patching 19.16.39 adds an option to restore old seekbar thumbnails.", "Patching 19.16.39 adds an option to restore old seekbar thumbnails.",
) { ) {
@ -27,18 +27,13 @@ val seekbarThumbnailsPatch = bytecodePatch(
versionCheckPatch, versionCheckPatch,
) )
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
)
)
execute { execute {
if (is_20_09_or_greater) {
// High quality seekbar thumbnails is partially broken in 20.09
// and the code is completely removed in 20.10+
return@execute
}
addResources("youtube", "layout.seekbar.seekbarThumbnailsPatch") addResources("youtube", "layout.seekbar.seekbarThumbnailsPatch")
if (is_19_17_or_greater) { if (is_19_17_or_greater) {

View File

@ -1,58 +1,11 @@
package app.revanced.patches.youtube.layout.hide.seekbar package app.revanced.patches.youtube.layout.hide.seekbar
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources import app.revanced.patches.youtube.interaction.seekbar.hideSeekbarPatch
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.layout.seekbar.seekbarColorPatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.patches.youtube.shared.seekbarFingerprint
import app.revanced.patches.youtube.shared.seekbarOnDrawFingerprint
val hideSeekbarPatch = bytecodePatch( @Deprecated("Patch was moved to app.revanced.patches.youtube.interaction.seekbar")
name = "Hide seekbar", val hideSeekbarPatch = bytecodePatch {
description = "Adds an option to hide the seekbar.",
) {
dependsOn( dependsOn(
sharedExtensionPatch, hideSeekbarPatch
settingsPatch,
seekbarColorPatch,
addResourcesPatch,
)
compatibleWith(
"com.google.android.youtube"(
"19.16.39",
"19.25.37",
"19.34.42",
"19.43.41",
"19.47.53",
"20.07.39",
),
)
execute {
addResources("youtube", "layout.hide.seekbar.hideSeekbarPatch")
PreferenceScreen.SEEKBAR.addPreferences(
SwitchPreference("revanced_hide_seekbar"),
SwitchPreference("revanced_hide_seekbar_thumbnail"),
)
seekbarOnDrawFingerprint.match(seekbarFingerprint.originalClassDef).method.addInstructionsWithLabels(
0,
"""
const/4 v0, 0x0
invoke-static { }, Lapp/revanced/extension/youtube/patches/HideSeekbarPatch;->hideSeekbar()Z
move-result v0
if-eqz v0, :hide_seekbar
return-void
:hide_seekbar
nop
""",
) )
} }
}