From 30afb13b445a3b4b2bb2a4f5ad356a2cbcf15f3c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 23 Sep 2023 20:03:05 +0200 Subject: [PATCH 1/3] fix(YouTube - Client spoof): Do not record feed videos to history by default --- .../SpoofSignatureVerificationPatch.kt | 4 +- ...SpoofSignatureVerificationResourcePatch.kt | 58 +++++++++++++++---- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt index 0e7a52095f..8aa7cc95e7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt @@ -49,7 +49,7 @@ object SpoofSignatureVerificationPatch : BytecodePatch( addInstructions( 0, """ - invoke-static {p$protobufParameterRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideProtobufParameter(Ljava/lang/String;)Ljava/lang/String; + invoke-static {p$protobufParameterRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->spoofParameter(Ljava/lang/String;)Ljava/lang/String; move-result-object p$protobufParameterRegister """ ) @@ -98,7 +98,7 @@ object SpoofSignatureVerificationPatch : BytecodePatch( """ iget-object v0, p0, $imageViewFieldName # copy imageview field to a register invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->seekbarImageViewCreated(Landroid/widget/ImageView;)V - """ + """ ) } } ?: throw ScrubbedPreviewLayoutFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt index b59dac611e..0efd9ab20d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt @@ -4,6 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -14,18 +15,51 @@ object SpoofSignatureVerificationResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_spoof_signature_verification", - StringResource("revanced_spoof_signature_verification_title", "Spoof app signature"), - StringResource("revanced_spoof_signature_verification_summary_on", - "App signature spoofed\\n\\n" - + "Side effects include:\\n" - + "• Ambient mode may not work\\n" - + "• Downloading videos may not work\\n" - + "• Seekbar thumbnails are always hidden"), - StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed\\n\\nVideo playback may not work"), - StringResource("revanced_spoof_signature_verification_user_dialog_message", - "Turning off this setting will cause video playback issues.") + PreferenceScreen( + key = "revanced_spoof_signature_verification", + title = StringResource( + "revanced_spoof_signature_verification_title", + "Spoof app signature" + ), + preferences = listOf( + SwitchPreference( + "revanced_spoof_signature_verification_enabled", + StringResource("revanced_spoof_signature_verification_enabled_title", "Spoof app signature"), + StringResource( + "revanced_spoof_signature_verification_enabled_summary_on", + "App signature spoofed\\n\\n" + + "Side effects include:\\n" + + "• No ambient mode\\n" + + "• Videos can't be downloaded\\n" + + "• Seekbar thumbnails not showing up" + ), + StringResource( + "revanced_spoof_signature_verification_enabled_summary_off", + "App signature not spoofed\\n\\nVideo playback may not work" + ), + StringResource( + "revanced_spoof_signature_verification_enabled_user_dialog_message", + "Turning off this setting will cause video playback issues." + ) + ), + SwitchPreference( + "revanced_spoof_signature_in_feed_enabled", + StringResource("revanced_spoof_signature_in_feed_enabled_title", "Spoof app signature in feed"), + StringResource( + "revanced_spoof_signature_in_feed_enabled_summary_on", + "App signature spoofed\\n\\n" + + "Automatically played videos in feed will forcibly be recorded in watch history" + ), + StringResource( + "revanced_spoof_signature_in_feed_enabled_summary_off", + "App signature not spoofed\\n\\nVideo playback in feed may not work" + ), + StringResource( + "revanced_spoof_signature_in_feed_enabled_user_dialog_message", + "Turning off this setting will cause video playback issues." + ) + ) + ) ) ) From 9b928eadae3b2ce1d5ca56849bb8e4bb4938e571 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 23 Sep 2023 20:06:55 +0200 Subject: [PATCH 2/3] refactor: Simplify naming of classes and keys --- .../youtube/misc/fix/playback/ClientSpoofPatch.kt | 2 +- ...natureVerificationPatch.kt => SpoofSignaturePatch.kt} | 9 ++++----- ...onResourcePatch.kt => SpoofSignatureResourcePatch.kt} | 2 +- .../fingerprints/ScrubbedPreviewLayoutFingerprint.kt | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) rename src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/{SpoofSignatureVerificationPatch.kt => SpoofSignaturePatch.kt} (95%) rename src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/{SpoofSignatureVerificationResourcePatch.kt => SpoofSignatureResourcePatch.kt} (98%) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt index d449a04ac3..ec4f1955a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt @@ -14,7 +14,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @Patch( name = "Client spoof", description = "Spoofs the client to allow playback.", - dependencies = [SpoofSignatureVerificationPatch::class], + dependencies = [SpoofSignaturePatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt index 8aa7cc95e7..ef47ee9502 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt @@ -18,14 +18,14 @@ import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @Patch( - description = "Spoofs the client to prevent playback issues.", + description = "Spoofs the signature to prevent playback issues.", dependencies = [ - SpoofSignatureVerificationResourcePatch::class, + SpoofSignatureResourcePatch::class, IntegrationsPatch::class, PlayerTypeHookPatch::class ] ) -object SpoofSignatureVerificationPatch : BytecodePatch( +object SpoofSignaturePatch : BytecodePatch( setOf( ProtobufParameterBuilderFingerprint, StoryboardThumbnailParentFingerprint, @@ -33,10 +33,9 @@ object SpoofSignatureVerificationPatch : BytecodePatch( ) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/patches/SpoofSignatureVerificationPatch;" + "Lapp/revanced/integrations/patches/SpoofSignaturePatch;" override fun execute(context: BytecodeContext) { - // hook parameter ProtobufParameterBuilderFingerprint.result?.let { val setParamMethod = context diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt index 0efd9ab20d..e8476fcdf9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureVerificationResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt @@ -10,7 +10,7 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) -object SpoofSignatureVerificationResourcePatch : ResourcePatch() { +object SpoofSignatureResourcePatch : ResourcePatch() { internal var scrubbedPreviewThumbnailResourceId: Long = -1 override fun execute(context: ResourceContext) { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/ScrubbedPreviewLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/ScrubbedPreviewLayoutFingerprint.kt index 0f58b36e7e..36bce605d7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/ScrubbedPreviewLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/ScrubbedPreviewLayoutFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.fix.playback.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.youtube.misc.fix.playback.SpoofSignatureVerificationResourcePatch +import app.revanced.patches.youtube.misc.fix.playback.SpoofSignatureResourcePatch import app.revanced.util.patch.LiteralValueFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -23,5 +23,5 @@ object ScrubbedPreviewLayoutFingerprint : LiteralValueFingerprint( Opcode.IPUT_OBJECT, // preview imageview ), // This resource is used in ~ 40 different locations, but this method has a distinct list of parameters to match to. - literalSupplier = { SpoofSignatureVerificationResourcePatch.scrubbedPreviewThumbnailResourceId } + literalSupplier = { SpoofSignatureResourcePatch.scrubbedPreviewThumbnailResourceId } ) \ No newline at end of file From e0ff463248826d80fd7a6d7e15fb776b60181434 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 23 Sep 2023 23:36:09 +0200 Subject: [PATCH 3/3] feat: Improve descriptions --- .../fix/playback/SpoofSignatureResourcePatch.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 e8476fcdf9..e328fbd53d 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 @@ -31,7 +31,7 @@ object SpoofSignatureResourcePatch : ResourcePatch() { + "Side effects include:\\n" + "• No ambient mode\\n" + "• Videos can't be downloaded\\n" - + "• Seekbar thumbnails not showing up" + + "• Seekbar thumbnails are hidden" ), StringResource( "revanced_spoof_signature_verification_enabled_summary_off", @@ -48,15 +48,14 @@ object SpoofSignatureResourcePatch : ResourcePatch() { StringResource( "revanced_spoof_signature_in_feed_enabled_summary_on", "App signature spoofed\\n\\n" - + "Automatically played videos in feed will forcibly be recorded in watch history" + + "Side effects include:\\n" + + "• Feed videos are missing subtitles\\n" + + "• Automatically played feed videos will show up in your watch history" ), StringResource( "revanced_spoof_signature_in_feed_enabled_summary_off", - "App signature not spoofed\\n\\nVideo playback in feed may not work" - ), - StringResource( - "revanced_spoof_signature_in_feed_enabled_user_dialog_message", - "Turning off this setting will cause video playback issues." + "App signature not spoofed for feed videos\n\n" + + "Feed videos will play for less than 1 minute before encountering playback issues" ) ) )