Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(YouTube - Client spoof): Do not record feed videos to history by default #3017

Merged
merged 3 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@ 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,
ScrubbedPreviewLayoutFingerprint
)
) {
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
Expand All @@ -49,7 +48,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
"""
)
Expand Down Expand Up @@ -98,7 +97,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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package app.revanced.patches.youtube.misc.fix.playback

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

@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class])
object SpoofSignatureResourcePatch : ResourcePatch() {
internal var scrubbedPreviewThumbnailResourceId: Long = -1

override fun execute(context: ResourceContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
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 are hidden"
),
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"
+ "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 for feed videos\n\n"
+ "Feed videos will play for less than 1 minute before encountering playback issues"
)
)
)
)
)

scrubbedPreviewThumbnailResourceId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "thumbnail"
}.id
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }
)