diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/SecondaryPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PiPNotificationFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/SecondaryPiPFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PiPNotificationFingerprint.kt index 576be3eed..2fa7e8c5d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/SecondaryPiPFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PiPNotificationFingerprint.kt @@ -5,12 +5,11 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -object SecondaryPiPFingerprint : MethodFingerprint( +object PiPNotificationFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), opcodes = listOf( - null, Opcode.CHECK_CAST, Opcode.IGET_OBJECT, Opcode.IF_EQZ, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PrimaryPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PrimaryPiPFingerprint.kt deleted file mode 100644 index d769a0cc5..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/fingerprints/PrimaryPiPFingerprint.kt +++ /dev/null @@ -1,21 +0,0 @@ -package app.revanced.patches.youtube.layout.pipnotification.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode - -object PrimaryPiPFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L"), - opcodes = listOf( - Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.INVOKE_VIRTUAL, - Opcode.CHECK_CAST, - Opcode.INVOKE_VIRTUAL, - Opcode.IPUT_BOOLEAN - ), - strings = listOf("honeycomb.Shell\$HomeActivity") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt index 1442aac9a..d517c5847 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pipnotification/patch/PiPNotificationPatch.kt @@ -5,13 +5,17 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.layout.pipnotification.fingerprints.PrimaryPiPFingerprint -import app.revanced.patches.youtube.layout.pipnotification.fingerprints.SecondaryPiPFingerprint +import app.revanced.patches.youtube.layout.pipnotification.fingerprints.PiPNotificationFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.getStringIndex +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @Patch @Name("Disable pip notification") @@ -19,26 +23,36 @@ import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch @DependsOn([SettingsPatch::class]) @YouTubeCompatibility class PiPNotificationPatch : BytecodePatch( - listOf( - PrimaryPiPFingerprint, - SecondaryPiPFingerprint - ) + listOf(PiPNotificationFingerprint) ) { override fun execute(context: BytecodeContext) { - arrayOf( - PrimaryPiPFingerprint, - SecondaryPiPFingerprint - ).forEach { fingerprint -> - fingerprint.result?.let { - it.mutableMethod.apply { - addInstruction( - it.scanResult.patternScanResult!!.endIndex - 4, - "return-void" - ) + PiPNotificationFingerprint.result?.let { + it.mutableMethod.apply { + var insertIndex = -1 + + val startIndex = it.scanResult.patternScanResult!!.startIndex - 6 + val endIndex = getStringIndex("honeycomb.Shell\$HomeActivity") + + for (index in endIndex downTo startIndex) { + if (getInstruction(index).opcode != Opcode.CHECK_CAST) continue + + val targetReference = + getInstruction(index).reference.toString() + + if (targetReference == "Lcom/google/apps/tiktok/account/AccountId;") { + insertIndex = index + 1 + + addInstruction( + insertIndex, + "return-void" + ) + } } - } ?: throw fingerprint.exception - } + if (insertIndex == -1) + throw PatchException("Couldn't find target Index") + } + } ?: throw PiPNotificationFingerprint.exception /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/fingerprints/PowerSaveModeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/fingerprints/PowerSaveModeFingerprint.kt index 70befb075..0b3060fb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/fingerprints/PowerSaveModeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/fingerprints/PowerSaveModeFingerprint.kt @@ -2,24 +2,19 @@ package app.revanced.patches.youtube.misc.ambientmode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.YtBrandBackgroundSolid +import app.revanced.util.bytecode.isWideLiteralExists import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode object PowerSaveModeFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L"), + parameters = listOf("Ljava/lang/Object;"), opcodes = listOf( - Opcode.IGET_OBJECT, - Opcode.CHECK_CAST, - Opcode.CHECK_CAST, - Opcode.IGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.RETURN_VOID + Opcode.IF_GT, + Opcode.IGET, + Opcode.ADD_INT_2ADDR ), - customFingerprint = { methodDef, _ -> methodDef.name == "accept" } + customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(YtBrandBackgroundSolid) && methodDef.name == "accept" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt index 9772b60e3..9bb8a3820 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/ambientmode/patch/PowerSaveModePatch.kt @@ -12,6 +12,7 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.youtube.misc.ambientmode.fingerprints.PowerSaveModeFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import com.android.tools.smali.dexlib2.Opcode @@ -22,7 +23,12 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Patch @Name("Bypass ambient mode restrictions") @Description("Bypass ambient mode restrictions in battery saver mode.") -@DependsOn([SettingsPatch::class]) +@DependsOn( + [ + SettingsPatch::class, + SharedResourceIdPatch::class + ] +) @YouTubeCompatibility class PowerSaveModePatch : BytecodePatch( listOf(PowerSaveModeFingerprint) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/language/fingerprints/GeneralPrefsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/language/fingerprints/GeneralPrefsFingerprint.kt index 122059eec..e15653e68 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/language/fingerprints/GeneralPrefsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/language/fingerprints/GeneralPrefsFingerprint.kt @@ -7,11 +7,12 @@ object GeneralPrefsFingerprint : MethodFingerprint( returnType = "V", parameters = emptyList(), opcodes = listOf( - Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT, Opcode.IF_NEZ, Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.GOTO ), strings = listOf("bedtime_reminder_toggle"), customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/GeneralPrefsFragment;") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt index 93e358278..21dd877ce 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/language/patch/LanguageSelectorPatch.kt @@ -26,7 +26,7 @@ class LanguageSelectorPatch : BytecodePatch( GeneralPrefsFingerprint.result?.let { it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.startIndex + 2 + val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1 val targetRegister = getInstruction(targetIndex).registerA addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt index a335caf6c..b615a61b7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/endscreencards/fingerprints/LayoutIconFingerprint.kt @@ -8,8 +8,6 @@ import com.android.tools.smali.dexlib2.Opcode object LayoutIconFingerprint : MethodFingerprint( returnType = "Landroid/view/View;", opcodes = listOf( - Opcode.CONST_4, - Opcode.CONST, Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, Opcode.CHECK_CAST, diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt index 6f2cb2aad..aa1fb9f0f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt @@ -13,9 +13,9 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.patch.litho.LithoThemePatch import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ControlsOverlayStyleFingerprint -import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.PlayerSeekbarColorFingerprint import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ShortsSeekbarColorFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.fingerprints.PlayerSeekbarColorFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarPlayedNotHighlightedColor diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt index cbed8d565..2a075d1f6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/fingerprints/TimeCounterFingerprint.kt @@ -7,38 +7,11 @@ import com.android.tools.smali.dexlib2.Opcode object TimeCounterFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf(), + parameters = emptyList(), returnType = "V", opcodes = listOf( - Opcode.RETURN_VOID, - Opcode.IGET_BOOLEAN, - Opcode.IF_EQZ, - Opcode.IGET_OBJECT, - Opcode.IGET_WIDE, - Opcode.IGET_WIDE, - Opcode.SUB_LONG_2ADDR, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IGET_OBJECT, - Opcode.IGET_WIDE, - Opcode.IGET_WIDE, Opcode.SUB_LONG_2ADDR, Opcode.IGET_WIDE, - Opcode.SUB_LONG_2ADDR, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IGET_OBJECT, - Opcode.IGET_WIDE, - Opcode.IGET_WIDE, - Opcode.SUB_LONG_2ADDR, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.RETURN_VOID - ), - customFingerprint = { _, classDef -> - // On older devices this fingerprint resolves very slowly. - // Speed this up by checking for the number of methods. - classDef.methods.count() == 14 || classDef.methods.count() == 15 - } + Opcode.SUB_LONG_2ADDR + ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt index 6810df794..2ed6353a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/timestamps/patch/HideTimeStampPatch.kt @@ -6,37 +6,47 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.seekbar.timestamps.fingerprints.TimeCounterFingerprint import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility +import app.revanced.patches.youtube.utils.fingerprints.PlayerSeekbarColorFingerprint +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SEEKBAR @Patch @Name("Hide time stamp") @Description("Hides timestamp in video player.") -@DependsOn([SettingsPatch::class]) +@DependsOn( + [ + SettingsPatch::class, + SharedResourceIdPatch::class, + ] +) @YouTubeCompatibility class HideTimeStampPatch : BytecodePatch( - listOf(TimeCounterFingerprint) + listOf(PlayerSeekbarColorFingerprint) ) { override fun execute(context: BytecodeContext) { - TimeCounterFingerprint.result?.let { - it.mutableMethod.apply { - addInstructionsWithLabels( - 0, """ + PlayerSeekbarColorFingerprint.result?.let { parentResult -> + TimeCounterFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ invoke-static {}, $SEEKBAR->hideTimeStamp()Z move-result v0 if-eqz v0, :show_time_stamp return-void """, ExternalLabel("show_time_stamp", getInstruction(0)) - ) - } - } ?: throw TimeCounterFingerprint.exception + ) + } + } ?: throw TimeCounterFingerprint.exception + } ?: throw PlayerSeekbarColorFingerprint.exception /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt index ff7c5edd5..398c17d0c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/shortscomponent/patch/ShortsSubscriptionsButtonPatch.kt @@ -74,8 +74,8 @@ class ShortsSubscriptionsButtonPatch : BytecodePatch( ) } } - } ?: throw ShortsSubscriptionsTabletFingerprint.exception - } ?: throw ShortsSubscriptionsTabletParentFingerprint.exception + } + } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt index 859f3b432..061a8b07c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/annotations/YouTubeCompatibility.kt @@ -4,19 +4,24 @@ import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package @Compatibility( - [Package( - "com.google.android.youtube", arrayOf( - "18.20.39", - "18.21.35", - "18.22.37", - "18.23.36", - "18.24.37", - "18.25.40", - "18.27.36", - "18.29.38", - "18.30.37" + [ + Package( + "com.google.android.youtube", + arrayOf( + "18.19.36", + "18.20.39", + "18.21.35", + "18.22.37", + "18.23.36", + "18.24.37", + "18.25.40", + "18.27.36", + "18.29.38", + "18.30.37", + "18.31.40" + ) ) - )] + ] ) @Target(AnnotationTarget.CLASS) internal annotation class YouTubeCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/PlayerSeekbarColorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/PlayerSeekbarColorFingerprint.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/PlayerSeekbarColorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/PlayerSeekbarColorFingerprint.kt index 83fc7f5d3..d0f300897 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/seekbarcolor/fingerprints/PlayerSeekbarColorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fingerprints/PlayerSeekbarColorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints +package app.revanced.patches.youtube.utils.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt index 5234a3516..4d40fc23a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -9,5 +9,5 @@ object UserAgentHeaderBuilderFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.INVOKE_VIRTUAL ), - strings = listOf("(Linux; U; Android "), + strings = listOf("(Linux; U; Android ") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/ProtobufParameterBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/ProtobufParameterBuilderFingerprint.kt index cc52fc641..bdcbfce42 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/ProtobufParameterBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/ProtobufParameterBuilderFingerprint.kt @@ -1,13 +1,35 @@ package app.revanced.patches.youtube.utils.fix.parameter.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode object ProtobufParameterBuilderFingerprint : MethodFingerprint( - opcodes = listOf( - Opcode.INVOKE_VIRTUAL_RANGE, // target reference - Opcode.MOVE_RESULT_OBJECT, - Opcode.IPUT_OBJECT + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "L", + parameters = listOf( + "Ljava/lang/String;", + "[B", + "Ljava/lang/String;", + "Ljava/lang/String;", + "I", + "I", + "Ljava/util/Set;", + "Ljava/lang/String;", + "Ljava/lang/String;", + "L", + "Z", + "Z", + "Z" ), - strings = listOf("Unexpected empty videoId.", "Prefetch request are disabled.") + opcodes = listOf( + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST, + Opcode.INVOKE_INTERFACE + ), + customFingerprint = { methodDef, _ -> + methodDef.name == "b" + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/patch/SpoofPlayerParameterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/patch/SpoofPlayerParameterPatch.kt index 91e4f32e1..4d23cecc2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/patch/SpoofPlayerParameterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/patch/SpoofPlayerParameterPatch.kt @@ -11,7 +11,6 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion. import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.ProtobufParameterBuilderFingerprint import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.ScrubbedPreviewLayoutFingerprint @@ -45,21 +44,16 @@ class SpoofPlayerParameterPatch : BytecodePatch( // hook parameter ProtobufParameterBuilderFingerprint.result?.let { - (context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) - .getMethod() as MutableMethod - ).apply { - val protobufParam = 3 + it.mutableMethod.apply { + val protobufParam = 3 - addInstructions( - 0, - """ + addInstructions( + 0, """ invoke-static {p$protobufParam}, $INTEGRATIONS_CLASS_DESCRIPTOR->overridePlayerParameter(Ljava/lang/String;)Ljava/lang/String; move-result-object p$protobufParam - """ - ) - } + """ + ) + } } ?: throw ProtobufParameterBuilderFingerprint.exception // When the player parameter is spoofed in incognito mode, this value will always be false diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/PlaybackSpeedPatchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/PlaybackSpeedPatchFingerprint.kt index 12bee3877..c1a5f84c1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/PlaybackSpeedPatchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/fingerprints/PlaybackSpeedPatchFingerprint.kt @@ -9,7 +9,7 @@ object PlaybackSpeedPatchFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, parameters = listOf("F"), customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("/PlaybackSpeedPatch;") + methodDef.definingClass == "Lapp/revanced/integrations/patches/video/PlaybackSpeedPatch;" && methodDef.name == "overrideSpeed" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/fingerprints/QuickActionsElementFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/fingerprints/QuickActionsElementFingerprint.kt index 4194e9e46..0357f725a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/fingerprints/QuickActionsElementFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/fingerprints/QuickActionsElementFingerprint.kt @@ -1,23 +1,18 @@ package app.revanced.patches.youtube.utils.quickactions.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.QuickActionsElementContainer import app.revanced.util.bytecode.isWideLiteralExists -import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.AccessFlags object QuickActionsElementFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("Landroid/view/View;"), returnType = "V", - opcodes = listOf( - Opcode.RETURN_VOID, - Opcode.IGET_OBJECT, - Opcode.CONST, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.CONST, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST - ), - customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(QuickActionsElementContainer) } + customFingerprint = { methodDef, _ -> + methodDef.isWideLiteralExists( + QuickActionsElementContainer + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/patch/QuickActionsHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/patch/QuickActionsHookPatch.kt index 4d0d62cc3..dcb6b036d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/patch/QuickActionsHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/quickactions/patch/QuickActionsHookPatch.kt @@ -8,8 +8,11 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.youtube.utils.quickactions.fingerprints.QuickActionsElementFingerprint import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.QuickActionsElementContainer import app.revanced.util.integrations.Constants.FULLSCREEN +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction @DependsOn([SharedResourceIdPatch::class]) class QuickActionsHookPatch : BytecodePatch( @@ -19,13 +22,18 @@ class QuickActionsHookPatch : BytecodePatch( QuickActionsElementFingerprint.result?.let { it.mutableMethod.apply { - val insertIndex = it.scanResult.patternScanResult!!.endIndex - val targetRegister = getInstruction(insertIndex).registerA + for (index in implementation!!.instructions.size - 1 downTo 0) { + if (getInstruction(index).opcode == Opcode.CONST && (getInstruction(index) as WideLiteralInstruction).wideLiteral == QuickActionsElementContainer) { + val targetRegister = + getInstruction(index + 2).registerA - addInstruction( - insertIndex, - "invoke-static {v$targetRegister}, $FULLSCREEN->hideQuickActions(Landroid/view/View;)V" - ) + addInstruction( + index + 3, + "invoke-static {v$targetRegister}, $FULLSCREEN->hideQuickActions(Landroid/view/View;)V" + ) + break + } + } } } ?: throw QuickActionsElementFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt index abe5854b7..31b651ee9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/patch/SharedResourceIdPatch.kt @@ -78,6 +78,7 @@ class SharedResourceIdPatch : ResourcePatch { var VideoZoomIndicatorLayout: Long = -1 var WordMarkHeader: Long = -1 var YoutubeControlsOverlay: Long = -1 + var YtBrandBackgroundSolid: Long = -1 var YtOutlineArrowTimeBlack: Long = -1 var YtOutlineFireBlack: Long = -1 var YtOutlineSearchBlack: Long = -1 @@ -154,6 +155,7 @@ class SharedResourceIdPatch : ResourcePatch { VideoZoomIndicatorLayout = find(ID, "video_zoom_indicator_layout") WordMarkHeader = find(ATTR, "ytWordmarkHeader") YoutubeControlsOverlay = find(ID, "youtube_controls_overlay") + YtBrandBackgroundSolid = find(ATTR, "ytBrandBackgroundSolid") YtOutlineArrowTimeBlack = find(DRAWABLE, "yt_outline_arrow_time_black_24") YtOutlineFireBlack = find(DRAWABLE, "yt_outline_fire_black_24") YtOutlineSearchBlack = find(DRAWABLE, "yt_outline_search_black_24") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt index f4057a36f..def13006f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/fingerprints/TextComponentContextFingerprint.kt @@ -10,7 +10,7 @@ object TextComponentContextFingerprint : MethodFingerprint( accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, parameters = listOf("L"), opcodes = listOf( - Opcode.IGET_OBJECT, // conversion context + Opcode.IGET_OBJECT, Opcode.IGET_OBJECT, Opcode.IGET_OBJECT, Opcode.IGET_BOOLEAN diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt index 2a1f02ecc..9157c824c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/patch/ReturnYouTubeDislikePatch.kt @@ -27,6 +27,7 @@ import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.patch.Retu import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.utils.videoid.general.patch.VideoIdPatch 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 @@ -79,9 +80,21 @@ class ReturnYouTubeDislikePatch : BytecodePatch( ) }.result?.let { it.mutableMethod.apply { - val conversionContextIndex = it.scanResult.patternScanResult!!.startIndex - conversionContextFieldReference = - getInstruction(conversionContextIndex).reference + val booleanIndex = it.scanResult.patternScanResult!!.endIndex + + for (index in booleanIndex downTo 0) { + if (getInstruction(index).opcode != Opcode.IGET_OBJECT) continue + + val targetReference = + getInstruction(index).reference.toString() + + if (targetReference.endsWith("Ljava/util/Map;")) { + conversionContextFieldReference = + getInstruction(index - 1).reference + + break + } + } } } ?: throw TextComponentContextFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt index 7f8c1ded2..133e656d2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/fingerprints/ShortsTextViewFingerprint.kt @@ -24,7 +24,5 @@ object ShortsTextViewFingerprint : MethodFingerprint( Opcode.IF_EQ, Opcode.RETURN_VOID, Opcode.IGET_OBJECT, // TextView field - Opcode.CHECK_CAST, - Opcode.IGET_BOOLEAN, // boolean field ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt index c224d31cc..b0f5b24e8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/shorts/patch/ReturnYouTubeDislikeShortsPatch.kt @@ -8,6 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint import app.revanced.util.integrations.Constants.UTILS_PATH +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction class ReturnYouTubeDislikeShortsPatch : BytecodePatch( @@ -18,12 +19,16 @@ class ReturnYouTubeDislikeShortsPatch : BytecodePatch( it.mutableMethod.apply { val patternResult = it.scanResult.patternScanResult!! + val isDisLikesBooleanIndex = + implementation!!.instructions.indexOfFirst { instruction -> + instruction.opcode == Opcode.IGET_BOOLEAN + } // If the field is true, the TextView is for a dislike button. val isDisLikesBooleanReference = - getInstruction(patternResult.endIndex).reference + getInstruction(isDisLikesBooleanIndex).reference val textViewFieldReference = // Like/Dislike button TextView field - getInstruction(patternResult.endIndex - 2).reference + getInstruction(patternResult.endIndex).reference // Check if the hooked TextView object is that of the dislike button. // If RYD is disabled, or the TextView object is not that of the dislike button, the execution flow is not interrupted.