fix(YouTube - ReturnYouTubeDislike): Fix text alignment on videos that don't use rolling number animations

This commit is contained in:
LisoUseInAIKyrios 2023-11-19 00:21:36 +02:00
parent 90987d821f
commit 8fe9df75ef
2 changed files with 41 additions and 0 deletions

View File

@ -207,6 +207,26 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
}
} ?: throw RollingNumberMeasureTextFingerprint.exception
// Additional text measurement method. Used if YouTube decides not to animate the likes count
// and sometimes used for initial video load.
RollingNumberStaticLabelMeasureTextFingerprint.also {
if (!it.resolve(context, RollingNumberMeasureTextParentFingerprint.result!!.classDef))
throw it.exception
}.result?.also {
it.mutableMethod.apply {
val measureTextIndex = it.scanResult.patternScanResult!!.startIndex + 1
val freeRegister = getInstruction<TwoRegisterInstruction>(0).registerA
addInstructions(
measureTextIndex + 1,
"""
move-result v$freeRegister
invoke-static {p1, v$freeRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onRollingNumberMeasured(Ljava/lang/String;F)F
"""
)
}
} ?: throw RollingNumberStaticLabelMeasureTextFingerprint.exception
// The rolling number Span is missing styling since it's initially set as a String.
// Modify the UI text view and use the styled like/dislike Span.
RollingNumberTextViewFingerprint.result?.let {

View File

@ -0,0 +1,21 @@
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
/**
* Resolves to class found in [RollingNumberMeasureTextParentFingerprint].
*/
object RollingNumberStaticLabelMeasureTextFingerprint : MethodFingerprint(
returnType = "F",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Ljava/lang/String;"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.RETURN
)
)