From e938ba99b55402f3336cdd18bd8d07780d5173a2 Mon Sep 17 00:00:00 2001 From: OxrxL <108184954+OxrxL@users.noreply.github.com> Date: Tue, 4 Oct 2022 07:43:01 +0200 Subject: [PATCH] fix(youtube/disable-startup-shorts-player): don't affect functionality of navigation bar (#716) --- .../fingerprints/UserWasInShortsFingerprint.kt | 12 ++++++++++++ .../patch/DisableShortsOnStartupPatch.kt | 13 ++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt index cae3effac..2132bdcb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt @@ -3,6 +3,7 @@ package app.revanced.patches.youtube.layout.startupshortsreset.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.startupshortsreset.annotations.StartupShortsResetCompatibility @@ -11,9 +12,20 @@ import org.jf.dexlib2.Opcode @Name("user-was-in-shorts-fingerprint") @MatchingMethod("Lkzb;", "e") +@FuzzyPatternScanMethod(3) @StartupShortsResetCompatibility @Version("0.0.1") object UserWasInShortsFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT, + ), strings = listOf("Failed to read user_was_in_shorts proto after successful warmup"), ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt index 87469390a..9ae9bf9d5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt @@ -16,6 +16,7 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Patch @DependsOn([IntegrationsPatch::class, SettingsPatch::class]) @@ -39,15 +40,17 @@ class DisableShortsOnStartupPatch : BytecodePatch( ) ) - val userWasInShortsMethod = UserWasInShortsFingerprint.result!!.mutableMethod + val userWasInShortsResult = UserWasInShortsFingerprint.result!! + val userWasInShortsMethod = userWasInShortsResult.mutableMethod + val moveResultIndex = userWasInShortsResult.scanResult.patternScanResult!!.endIndex userWasInShortsMethod.addInstructions( - 0, """ + moveResultIndex + 1, """ invoke-static { }, Lapp/revanced/integrations/patches/DisableStartupShortsPlayerPatch;->disableStartupShortsPlayer()Z - move-result v0 - if-eqz v0, :cond_startup_shorts_reset + move-result v5 + if-eqz v5, :disable_shorts_player return-void - :cond_startup_shorts_reset + :disable_shorts_player nop """ )