From 5e8a2d3fe77a4a08ea32e7dc22f2c8e4048b7a6b Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 25 Sep 2023 23:50:42 +0200 Subject: [PATCH] fix(YouTube - Client spoof): Display seekbar thumbnails in high quality --- .../misc/fix/playback/SpoofSignaturePatch.kt | 27 ++++++++++++++++--- .../playback/SpoofSignatureResourcePatch.kt | 3 +-- .../StoryboardRendererInitFingerprint.kt | 15 +++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/StoryboardRendererInitFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt index 301681e4b..003f3a07e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt @@ -23,15 +23,16 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction SpoofSignatureResourcePatch::class, IntegrationsPatch::class, PlayerTypeHookPatch::class, - VideoInformationPatch::class + VideoInformationPatch::class, ] ) object SpoofSignaturePatch : BytecodePatch( setOf( ProtobufParameterBuilderFingerprint, + PlayerResponseModelImplFingerprint, StoryboardThumbnailParentFingerprint, StoryboardRendererSpecFingerprint, - PlayerResponseModelImplFingerprint + StoryboardRendererInitFingerprint ) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = @@ -100,7 +101,7 @@ object SpoofSignaturePatch : BytecodePatch( addInstructions( getStoryBoardIndex, """ - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->getStoryboardRendererSpec()Ljava/lang/String; + invoke-static { v$getStoryBoardRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getStoryboardRendererSpec(Ljava/lang/String;)Ljava/lang/String; move-result-object v$getStoryBoardRegister """ ) @@ -115,13 +116,31 @@ object SpoofSignaturePatch : BytecodePatch( 0, """ if-nez p$storyBoardUrlParams, :ignore - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->getStoryboardRendererSpec()Ljava/lang/String; + invoke-static { p$storyBoardUrlParams }, $INTEGRATIONS_CLASS_DESCRIPTOR->getStoryboardRendererSpec(Ljava/lang/String;)Ljava/lang/String; move-result-object p$storyBoardUrlParams """, ExternalLabel("ignore", getInstruction(0)) ) } } ?: throw StoryboardRendererSpecFingerprint.exception + + // Hook recommended value + StoryboardRendererInitFingerprint.result?.let { + val moveOriginalRecommendedValueIndex = it.scanResult.patternScanResult!!.endIndex + + val originalValueRegister = it.mutableMethod + .getInstruction(moveOriginalRecommendedValueIndex).registerA + + it.mutableMethod.apply { + addInstructions( + moveOriginalRecommendedValueIndex + 1, + """ + invoke-static { v$originalValueRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getRecommendedLevel(I)I + move-result v$originalValueRegister + """ + ) + } + } ?: throw StoryboardRendererInitFingerprint.exception } } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt index 6919aa966..f89d9e002 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt @@ -30,8 +30,7 @@ object SpoofSignatureResourcePatch : ResourcePatch() { "App signature spoofed\\n\\n" + "Side effects include:\\n" + "• No ambient mode\\n" - + "• Videos cannot be downloaded\\n" - + "• Low quality seekbar thumbnails (No thumbnails for age restricted or paid videos)" + + "• Videos cannot be downloaded" ), StringResource( "revanced_spoof_signature_verification_enabled_summary_off", diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/StoryboardRendererInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/StoryboardRendererInitFingerprint.kt new file mode 100644 index 000000000..9dca47f81 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/StoryboardRendererInitFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.youtube.misc.fix.playback.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import com.android.tools.smali.dexlib2.Opcode + +object StoryboardRendererInitFingerprint : MethodFingerprint( + strings = listOf("#-1#"), + opcodes = listOf( + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IPUT_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT + ) +)