fix(YouTube - Seekbar): Correctly hide the feed seekbar with target 20.07

This commit is contained in:
LisoUseInAIKyrios 2025-04-02 17:54:17 +02:00
parent 9f0efab3a1
commit ddc6e4c34f
3 changed files with 38 additions and 31 deletions

View File

@ -226,6 +226,7 @@ public final class SeekbarColorPatch {
} }
private static String loadRawResourceAsString(int resourceId) { private static String loadRawResourceAsString(int resourceId) {
//noinspection CharsetObjectCanBeUsed
try (InputStream inputStream = Utils.getContext().getResources().openRawResource(resourceId); try (InputStream inputStream = Utils.getContext().getResources().openRawResource(resourceId);
Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name()).useDelimiter("\\A")) { Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name()).useDelimiter("\\A")) {
return scanner.next(); return scanner.next();
@ -281,6 +282,20 @@ public final class SeekbarColorPatch {
/** /**
* Injection point. * Injection point.
* 19.49+
*/
public static int[] getPlayerLinearGradient(int[] original, int x0, int y1) {
// This hook is used for both the player and the feed.
// Feed usage always has x0 and y1 value of zero, and the player is always non zero.
if (HIDE_SEEKBAR_THUMBNAIL_ENABLED && x0 == 0 && y1 == 0) {
return HIDDEN_SEEKBAR_GRADIENT_COLORS;
}
return getPlayerLinearGradient(original);
}
/**
* Injection point.
* Pre 19.49
*/ */
public static int[] getPlayerLinearGradient(int[] original) { public static int[] getPlayerLinearGradient(int[] original) {
return SEEKBAR_CUSTOM_COLOR_ENABLED return SEEKBAR_CUSTOM_COLOR_ENABLED

View File

@ -84,31 +84,14 @@ internal val playerLinearGradientFingerprint = fingerprint {
} }
/** /**
* 19.46 - 19.47 * 19.25 - 19.47
*/ */
internal val playerLinearGradientLegacy1946Fingerprint = fingerprint { internal val playerLinearGradientLegacyFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
parameters("I", "I", "I", "I")
returns("V") returns("V")
opcodes( opcodes(
Opcode.FILLED_NEW_ARRAY, Opcode.FILLED_NEW_ARRAY,
Opcode.MOVE_RESULT_OBJECT Opcode.MOVE_RESULT_OBJECT
) )
custom { method, _ ->
method.name == "setBounds" && method.containsLiteralInstruction(ytYoutubeMagentaColorId)
}
}
/**
* 19.25 - 19.45
*/
internal val playerLinearGradientLegacy1925Fingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
parameters("Landroid/content/Context;")
opcodes(
Opcode.FILLED_NEW_ARRAY,
Opcode.MOVE_RESULT_OBJECT
)
literal { ytYoutubeMagentaColorId } literal { ytYoutubeMagentaColorId }
} }

View File

@ -1,5 +1,6 @@
package app.revanced.patches.youtube.layout.seekbar package app.revanced.patches.youtube.layout.seekbar
import app.revanced.patcher.Fingerprint
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
@ -310,13 +311,14 @@ val seekbarColorPatch = bytecodePatch(
""" """
) )
val playerFingerprint = val playerFingerprint: Fingerprint
val checkGradientCoordinates: Boolean
if (is_19_49_or_greater) { if (is_19_49_or_greater) {
playerLinearGradientFingerprint playerFingerprint = playerLinearGradientFingerprint
} else if (is_19_46_or_greater) { checkGradientCoordinates = true
playerLinearGradientLegacy1946Fingerprint
} else { } else {
playerLinearGradientLegacy1925Fingerprint playerFingerprint = playerLinearGradientLegacyFingerprint
checkGradientCoordinates = false
} }
playerFingerprint.let { playerFingerprint.let {
@ -326,10 +328,17 @@ val seekbarColorPatch = bytecodePatch(
addInstructions( addInstructions(
index + 1, index + 1,
if (checkGradientCoordinates) {
"""
invoke-static { v$register, p0, p1 }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerLinearGradient([III)[I
move-result-object v$register
"""
} else {
""" """
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerLinearGradient([I)[I invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerLinearGradient([I)[I
move-result-object v$register move-result-object v$register
""" """
}
) )
} }
} }