diff --git a/src/main/kotlin/app/revanced/patches/shared/textcomponent/TextComponentPatch.kt b/src/main/kotlin/app/revanced/patches/shared/textcomponent/TextComponentPatch.kt new file mode 100644 index 000000000..44aa2ee80 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/textcomponent/TextComponentPatch.kt @@ -0,0 +1,135 @@ +package app.revanced.patches.shared.textcomponent + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchException +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.shared.textcomponent.fingerprints.SpannableStringBuilderFingerprint +import app.revanced.patches.shared.textcomponent.fingerprints.TextComponentConstructorFingerprint +import app.revanced.patches.shared.textcomponent.fingerprints.TextComponentContextFingerprint +import app.revanced.util.alsoResolve +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstruction +import app.revanced.util.indexOfFirstInstructionOrThrow +import app.revanced.util.resultOrThrow +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 +import com.android.tools.smali.dexlib2.iface.reference.FieldReference +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +object TextComponentPatch : BytecodePatch( + setOf( + SpannableStringBuilderFingerprint, + TextComponentConstructorFingerprint, + ) +) { + override fun execute(context: BytecodeContext) { + + SpannableStringBuilderFingerprint.resultOrThrow().mutableMethod.apply { + spannedMethod = this + spannedIndex = SpannableStringBuilderFingerprint.indexOfSpannableStringInstruction(this) + spannedRegister = getInstruction(spannedIndex).registerC + spannedContextRegister = + getInstruction(0).registerA + + replaceInstruction( + spannedIndex, + "nop" + ) + addInstruction( + ++spannedIndex, + "invoke-static {v$spannedRegister}, ${SpannableStringBuilderFingerprint.SPANNABLE_STRING_REFERENCE}" + ) + } + + TextComponentContextFingerprint.alsoResolve( + context, TextComponentConstructorFingerprint + ).let { + it.mutableMethod.apply { + textComponentMethod = this + val conversionContextFieldIndex = indexOfFirstInstructionOrThrow { + getReference()?.type == "Ljava/util/Map;" + } - 1 + val conversionContextFieldReference = + getInstruction(conversionContextFieldIndex).reference + + // ~ YouTube 19.32.xx + val legacyCharSequenceIndex = indexOfFirstInstruction { + getReference()?.type == "Ljava/util/BitSet;" + } - 1 + val charSequenceIndex = indexOfFirstInstruction { + val reference = getReference() + opcode == Opcode.INVOKE_VIRTUAL && + reference?.returnType == "V" && + reference.parameterTypes.firstOrNull() == "Ljava/lang/CharSequence;" + } + + val insertIndex: Int + + if (legacyCharSequenceIndex > -2) { + textComponentRegister = + getInstruction(legacyCharSequenceIndex).registerA + insertIndex = legacyCharSequenceIndex - 1 + } else if (charSequenceIndex > -1) { + textComponentRegister = + getInstruction(charSequenceIndex).registerD + insertIndex = charSequenceIndex + } else { + throw PatchException("Could not find insert index") + } + + textComponentContextRegister = getInstruction( + indexOfFirstInstructionOrThrow(insertIndex, Opcode.IGET_OBJECT) + ).registerA + + addInstructions( + insertIndex, """ + move-object/from16 v$textComponentContextRegister, p0 + iget-object v$textComponentContextRegister, v$textComponentContextRegister, $conversionContextFieldReference + """ + ) + textComponentIndex = insertIndex + 2 + } + } + } + + private lateinit var spannedMethod: MutableMethod + private var spannedIndex = 0 + private var spannedRegister = 0 + private var spannedContextRegister = 0 + + private lateinit var textComponentMethod: MutableMethod + private var textComponentIndex = 0 + private var textComponentRegister = 0 + private var textComponentContextRegister = 0 + + fun hookSpannableString( + classDescriptor: String, + methodName: String + ) = spannedMethod.addInstructions( + spannedIndex, """ + invoke-static {v$spannedContextRegister, v$spannedRegister}, $classDescriptor->$methodName(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; + move-result-object v$spannedRegister + """ + ) + + fun hookTextComponent( + classDescriptor: String, + methodName: String = "onLithoTextLoaded" + ) = textComponentMethod.apply { + addInstructions( + textComponentIndex, """ + invoke-static {v$textComponentContextRegister, v$textComponentRegister}, $classDescriptor->$methodName(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; + move-result-object v$textComponentRegister + """ + ) + textComponentIndex += 2 + } +} + diff --git a/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/SpannableStringBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/SpannableStringBuilderFingerprint.kt new file mode 100644 index 000000000..1d88bab53 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/SpannableStringBuilderFingerprint.kt @@ -0,0 +1,26 @@ +package app.revanced.patches.shared.textcomponent.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.patches.shared.textcomponent.fingerprints.SpannableStringBuilderFingerprint.indexOfSpannableStringInstruction +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstruction +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.Method +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +internal object SpannableStringBuilderFingerprint : MethodFingerprint( + returnType = "Ljava/lang/CharSequence;", + strings = listOf("Failed to set PB Style Run Extension in TextComponentSpec. Extension id: %s"), + customFingerprint = { methodDef, _ -> + indexOfSpannableStringInstruction(methodDef) >= 0 + } +) { + const val SPANNABLE_STRING_REFERENCE = + "Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;" + + fun indexOfSpannableStringInstruction(methodDef: Method) = + methodDef.indexOfFirstInstruction { + opcode == Opcode.INVOKE_STATIC && + getReference()?.toString() == SPANNABLE_STRING_REFERENCE + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/TextComponentConstructorFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/TextComponentConstructorFingerprint.kt index fea97280e..264d3d178 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/TextComponentConstructorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints +package app.revanced.patches.shared.textcomponent.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/TextComponentContextFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/TextComponentContextFingerprint.kt index 85798107a..7815f6cca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/textcomponent/fingerprints/TextComponentContextFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints +package app.revanced.patches.shared.textcomponent.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt index e5ad5ca36..bc7f688f3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt @@ -11,6 +11,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.litho.LithoFilterPatch +import app.revanced.patches.shared.textcomponent.TextComponentPatch import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsButtonFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPaidPromotionFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPausedHeaderFingerprint @@ -18,7 +19,6 @@ import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPivotLe import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletParentFingerprint import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE -import app.revanced.patches.youtube.utils.fingerprints.TextComponentSpecFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH @@ -35,7 +35,6 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.Right import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT -import app.revanced.util.getReference import app.revanced.util.getWalkerMethod import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow @@ -44,7 +43,6 @@ import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.replaceLiteralInstructionCall import app.revanced.util.resultOrThrow import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @@ -65,7 +63,8 @@ object ShortsComponentPatch : BaseBytecodePatch( ShortsRepeatPatch::class, ShortsTimeStampPatch::class, ShortsToolBarPatch::class, - VideoInformationPatch::class + TextComponentPatch::class, + VideoInformationPatch::class, ), compatiblePackages = COMPATIBLE_PACKAGE, fingerprints = setOf( @@ -74,7 +73,6 @@ object ShortsComponentPatch : BaseBytecodePatch( ShortsPausedHeaderFingerprint, ShortsPivotLegacyFingerprint, ShortsSubscriptionsTabletParentFingerprint, - TextComponentSpecFingerprint ) ) { private const val INTEGRATION_CLASS_DESCRIPTOR = @@ -324,29 +322,7 @@ object ShortsComponentPatch : BaseBytecodePatch( // region patch for return shorts channel name - TextComponentSpecFingerprint.resultOrThrow().let { - it.mutableMethod.apply { - val insertIndex = indexOfFirstInstructionOrThrow { - getReference()?.toString() == "Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;" - } - val charSequenceRegister = - getInstruction(insertIndex).registerC - val conversionContextRegister = - getInstruction(0).registerA - - val replaceReference = - getInstruction(insertIndex).reference - - addInstructions( - insertIndex + 1, """ - invoke-static {v$conversionContextRegister, v$charSequenceRegister}, $INTEGRATION_CLASS_DESCRIPTOR->onCharSequenceLoaded(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; - move-result-object v$charSequenceRegister - invoke-static {v$charSequenceRegister}, $replaceReference - """ - ) - removeInstruction(insertIndex) - } - } + TextComponentPatch.hookSpannableString(INTEGRATION_CLASS_DESCRIPTOR, "onCharSequenceLoaded") VideoInformationPatch.hookShorts("$INTEGRATION_CLASS_DESCRIPTOR->newShortsVideoStarted(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JZ)V") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/TextComponentSpecFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/TextComponentSpecFingerprint.kt deleted file mode 100644 index f698f4a9b..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/TextComponentSpecFingerprint.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.youtube.utils.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint - -internal object TextComponentSpecFingerprint : MethodFingerprint( - returnType = "Ljava/lang/CharSequence;", - strings = listOf("Failed to set PB Style Run Extension in TextComponentSpec. Extension id: %s") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt index a580ea3ca..772cdaf9a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt @@ -2,34 +2,22 @@ package app.revanced.patches.youtube.utils.returnyoutubedislike.general import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.patcher.patch.PatchException import app.revanced.patches.shared.litho.LithoFilterPatch +import app.revanced.patches.shared.textcomponent.TextComponentPatch import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.DislikeFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.LikeFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.RemoveLikeFingerprint -import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentConstructorFingerprint -import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.TextComponentContextFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.ReturnYouTubeDislikeRollingNumberPatch import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.ReturnYouTubeDislikeShortsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.patches.youtube.video.videoid.VideoIdPatch -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstruction -import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.resultOrThrow -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 -import com.android.tools.smali.dexlib2.iface.reference.FieldReference -import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") object ReturnYouTubeDislikePatch : BaseBytecodePatch( @@ -40,6 +28,7 @@ object ReturnYouTubeDislikePatch : BaseBytecodePatch( ReturnYouTubeDislikeRollingNumberPatch::class, ReturnYouTubeDislikeShortsPatch::class, SettingsPatch::class, + TextComponentPatch::class, VideoInformationPatch::class ), compatiblePackages = COMPATIBLE_PACKAGE, @@ -47,7 +36,6 @@ object ReturnYouTubeDislikePatch : BaseBytecodePatch( DislikeFingerprint, LikeFingerprint, RemoveLikeFingerprint, - TextComponentConstructorFingerprint ) ) { private const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = @@ -70,59 +58,7 @@ object ReturnYouTubeDislikePatch : BaseBytecodePatch( ) } - - TextComponentConstructorFingerprint.resultOrThrow().let { parentResult -> - // Resolves fingerprints - TextComponentContextFingerprint.resolve(context, parentResult.classDef) - - TextComponentContextFingerprint.resultOrThrow().let { - it.mutableMethod.apply { - val conversionContextFieldIndex = indexOfFirstInstructionOrThrow { - getReference()?.type == "Ljava/util/Map;" - } - 1 - val conversionContextFieldReference = - getInstruction(conversionContextFieldIndex).reference - - val charSequenceIndex1932 = indexOfFirstInstruction { - getReference()?.type == "Ljava/util/BitSet;" - } - 1 - val charSequenceIndex1933 = indexOfFirstInstruction { - val reference = getReference() - opcode == Opcode.INVOKE_VIRTUAL && - reference?.returnType == "V" && - reference.parameterTypes.firstOrNull() == "Ljava/lang/CharSequence;" - } - - val insertIndex: Int - val charSequenceRegister: Int - - if (charSequenceIndex1932 > -2) { - charSequenceRegister = - getInstruction(charSequenceIndex1932).registerA - insertIndex = charSequenceIndex1932 - 1 - } else if (charSequenceIndex1933 > -1) { - charSequenceRegister = - getInstruction(charSequenceIndex1933).registerD - insertIndex = charSequenceIndex1933 - } else { - throw PatchException("Could not find insert index") - } - - val freeRegister = getInstruction( - indexOfFirstInstructionOrThrow(insertIndex, Opcode.IGET_OBJECT) - ).registerA - - addInstructions( - insertIndex, """ - move-object/from16 v$freeRegister, p0 - iget-object v$freeRegister, v$freeRegister, $conversionContextFieldReference - invoke-static {v$freeRegister, v$charSequenceRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onLithoTextLoaded(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; - move-result-object v$charSequenceRegister - """ - ) - } - } - } + TextComponentPatch.hookTextComponent(INTEGRATIONS_RYD_CLASS_DESCRIPTOR) // region Inject newVideoLoaded event handler to update dislikes when a new video is loaded. VideoIdPatch.hookVideoId("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V") 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 d174f5ece..f26911ea0 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 @@ -1,33 +1,29 @@ package app.revanced.patches.youtube.utils.returnyoutubedislike.shorts import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels 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.fingerprints.TextComponentSpecFingerprint +import app.revanced.patches.shared.textcomponent.TextComponentPatch import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint import app.revanced.patches.youtube.utils.settings.SettingsPatch -import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow import app.revanced.util.resultOrThrow 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 -import com.android.tools.smali.dexlib2.iface.reference.MethodReference -@Patch(dependencies = [SettingsPatch::class]) +@Patch( + dependencies = [ + SettingsPatch::class, + TextComponentPatch::class + ] +) object ReturnYouTubeDislikeShortsPatch : BytecodePatch( - setOf( - ShortsTextViewFingerprint, - TextComponentSpecFingerprint - ) + setOf(ShortsTextViewFingerprint) ) { private const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR = "$UTILS_PATH/ReturnYouTubeDislikePatch;" @@ -71,31 +67,8 @@ object ReturnYouTubeDislikeShortsPatch : BytecodePatch( } } - if (!SettingsPatch.upward1834) { - return - } - - TextComponentSpecFingerprint.resultOrThrow().let { - it.mutableMethod.apply { - val insertIndex = indexOfFirstInstructionOrThrow { - getReference()?.toString() == "Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;" - } - val charSequenceRegister = - getInstruction(insertIndex).registerC - val conversionContextRegister = - getInstruction(0).registerA - 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) - } + if (SettingsPatch.upward1834) { + TextComponentPatch.hookSpannableString(INTEGRATIONS_RYD_CLASS_DESCRIPTOR, "onCharSequenceLoaded") } } }