diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt index ccb4939fa..2b1c2bfcd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt @@ -2,19 +2,13 @@ package app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.util.bytecode.isWide32LiteralExists import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode object UserWasInShortsFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("Ljava/lang/Object;"), - opcodes = listOf( - Opcode.CHECK_CAST, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT - ), strings = listOf("Failed to read user_was_in_shorts proto after successful warmup"), + customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45381394) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt index ca23f6b09..17c87ed1a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/startupshortsreset/patch/DisableShortsOnStartupPatch.kt @@ -13,6 +13,7 @@ import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.shorts.startupshortsreset.fingerprints.UserWasInShortsFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.getWide32LiteralIndex import app.revanced.util.integrations.Constants.SHORTS import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -28,17 +29,18 @@ class DisableShortsOnStartupPatch : BytecodePatch( UserWasInShortsFingerprint.result?.let { it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.endIndex - val register = getInstruction(targetIndex).registerA + 2 + val insertIndex = getWide32LiteralIndex(45381394) + val insertRegister = getInstruction(insertIndex).registerA + addInstructionsWithLabels( - targetIndex + 1, + insertIndex, """ invoke-static { }, $SHORTS->disableStartupShortsPlayer()Z - move-result v$register - if-eqz v$register, :show_startup_shorts_player + move-result v$insertRegister + if-eqz v$insertRegister, :show_startup_shorts_player return-void """, - ExternalLabel("show_startup_shorts_player", getInstruction(targetIndex + 1)) + ExternalLabel("show_startup_shorts_player", getInstruction(insertIndex)) ) } } ?: throw UserWasInShortsFingerprint.exception