diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 35879b1c6..4ad80d2a8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -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(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 { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberStaticLabelMeasureTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberStaticLabelMeasureTextFingerprint.kt new file mode 100644 index 000000000..faed48d17 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/fingerprints/RollingNumberStaticLabelMeasureTextFingerprint.kt @@ -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 + ) +) \ No newline at end of file