From 855ef3a21dd6563efbccf10496d72c5f62720e77 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sat, 14 Oct 2023 06:17:56 +0900 Subject: [PATCH] fix(YouTube/Return YouTube Dislike): new type of Shorts RYD patch has also been applied to YouTube versions below v18.33.40 --- .../shorts/ReturnYouTubeDislikeShortsPatch.kt | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/ReturnYouTubeDislikeShortsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/ReturnYouTubeDislikeShortsPatch.kt index 0886c92d6..caf3ba15e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/ReturnYouTubeDislikeShortsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/ReturnYouTubeDislikeShortsPatch.kt @@ -7,15 +7,18 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.TextComponentSpecFingerprint +import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.integrations.Constants.UTILS_PATH import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction +@Patch(dependencies = [SettingsPatch::class]) object ReturnYouTubeDislikeShortsPatch : BytecodePatch( setOf( ShortsTextViewFingerprint, @@ -59,26 +62,27 @@ object ReturnYouTubeDislikeShortsPatch : BytecodePatch( } } ?: throw ShortsTextViewFingerprint.exception - TextComponentSpecFingerprint.result?.let { - it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.startIndex + if (SettingsPatch.upward1834) { + TextComponentSpecFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = it.scanResult.patternScanResult!!.startIndex - val charSequenceRegister = - getInstruction(insertIndex).registerC - val conversionContextRegister = getInstruction(0).registerA + val charSequenceRegister = getInstruction(insertIndex).registerC + val conversionContextRegister = getInstruction(0).registerA - val replaceReference = getInstruction(insertIndex).reference + val replaceReference = getInstruction(insertIndex).reference - addInstructions( - insertIndex + 1, """ - invoke-static {v$conversionContextRegister, v$charSequenceRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onCharSequenceLoaded(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; - move-result-object v$charSequenceRegister - invoke-static {v$charSequenceRegister}, $replaceReference - """ - ) - removeInstruction(insertIndex) - } - } ?: throw TextComponentSpecFingerprint.exception + addInstructions( + insertIndex + 1, """ + invoke-static {v$conversionContextRegister, v$charSequenceRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onCharSequenceLoaded(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; + move-result-object v$charSequenceRegister + invoke-static {v$charSequenceRegister}, $replaceReference + """ + ) + removeInstruction(insertIndex) + } + } ?: throw TextComponentSpecFingerprint.exception + } } private const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR =