mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 09:07:46 +01:00
fix(YouTube - Spoof client): show video time and chapters while using seekbar (#2607)
This commit is contained in:
parent
1f25b62008
commit
9546d12643
6 changed files with 167 additions and 22 deletions
|
@ -0,0 +1,27 @@
|
||||||
|
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationResourcePatch
|
||||||
|
import app.revanced.util.patch.LiteralValueFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object ScrubbedPreviewLayoutFingerprint : LiteralValueFingerprint(
|
||||||
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("Landroid/content/Context;", "Landroid/util/AttributeSet;", "I", "I"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.CONST,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.CHECK_CAST,
|
||||||
|
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.
|
||||||
|
literal = SpoofSignatureVerificationResourcePatch.scrubbedPreviewThumbnailResourceId
|
||||||
|
)
|
|
@ -0,0 +1,23 @@
|
||||||
|
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves using the class found in [StoryboardThumbnailParentFingerprint].
|
||||||
|
*/
|
||||||
|
object StoryboardThumbnailFingerprint : MethodFingerprint(
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
returnType = "Z",
|
||||||
|
parameters = listOf(),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.IF_GTZ,
|
||||||
|
Opcode.GOTO,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.RETURN,
|
||||||
|
Opcode.RETURN, // Last instruction of method.
|
||||||
|
),
|
||||||
|
)
|
|
@ -0,0 +1,17 @@
|
||||||
|
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Here lies code that creates the seekbar thumbnails.
|
||||||
|
*
|
||||||
|
* An additional change here might force the thumbnails to be created,
|
||||||
|
* or possibly a change somewhere else (maybe involving YouTube 18.23.35 class `hte`)
|
||||||
|
*/
|
||||||
|
object StoryboardThumbnailParentFingerprint : MethodFingerprint(
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
returnType = "Landroid/graphics/Bitmap;",
|
||||||
|
strings = listOf("Storyboard regionDecoder.decodeRegion exception - "),
|
||||||
|
)
|
|
@ -1,6 +1,5 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
|
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
|
||||||
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
|
|
@ -7,47 +7,35 @@ import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.data.toMethodWalker
|
import app.revanced.patcher.data.toMethodWalker
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.*
|
||||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
|
||||||
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
|
||||||
@Name("Spoof signature verification")
|
@Name("Spoof signature verification")
|
||||||
@Description("Spoofs a patched client to prevent playback issues.")
|
@Description("Spoofs a patched client to prevent playback issues.")
|
||||||
@DependsOn([
|
@DependsOn([
|
||||||
|
SpoofSignatureVerificationResourcePatch::class,
|
||||||
IntegrationsPatch::class,
|
IntegrationsPatch::class,
|
||||||
SettingsPatch::class,
|
PlayerTypeHookPatch::class
|
||||||
PlayerTypeHookPatch::class,
|
|
||||||
])
|
])
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class SpoofSignatureVerificationPatch : BytecodePatch(
|
class SpoofSignatureVerificationPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
ProtobufParameterBuilderFingerprint,
|
ProtobufParameterBuilderFingerprint,
|
||||||
|
StoryboardThumbnailParentFingerprint,
|
||||||
|
ScrubbedPreviewLayoutFingerprint,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
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"
|
|
||||||
+ "• Seekbar thumbnails are hidden\\n"
|
|
||||||
+ "• Downloading videos may not work"),
|
|
||||||
StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed"),
|
|
||||||
StringResource("revanced_spoof_signature_verification_user_dialog_message",
|
|
||||||
"Turning off this setting may cause playback issues.")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// hook parameter
|
// hook parameter
|
||||||
ProtobufParameterBuilderFingerprint.result?.let {
|
ProtobufParameterBuilderFingerprint.result?.let {
|
||||||
|
@ -68,6 +56,53 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
|
||||||
}
|
}
|
||||||
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
|
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
|
||||||
|
// When signature spoofing is enabled, the seekbar when tapped does not show
|
||||||
|
// the video time, chapter names, or the video thumbnail.
|
||||||
|
// Changing the value returned of this method forces all of these to show up,
|
||||||
|
// except the thumbnails are blank, which is handled with the patch below.
|
||||||
|
StoryboardThumbnailParentFingerprint.result ?: return StoryboardThumbnailParentFingerprint.toErrorResult()
|
||||||
|
StoryboardThumbnailFingerprint.resolve(context, StoryboardThumbnailParentFingerprint.result!!.classDef)
|
||||||
|
StoryboardThumbnailFingerprint.result?.apply {
|
||||||
|
val endIndex = scanResult.patternScanResult!!.endIndex
|
||||||
|
// Replace existing instruction to preserve control flow label.
|
||||||
|
// The replaced return instruction always returns false
|
||||||
|
// (it is the 'no thumbnails found' control path),
|
||||||
|
// so there is no need to pass the existing return value to integrations.
|
||||||
|
mutableMethod.replaceInstruction(
|
||||||
|
endIndex,
|
||||||
|
"""
|
||||||
|
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarThumbnailOverrideValue()Z
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
// Since this is end of the method must replace one line then add the rest.
|
||||||
|
mutableMethod.addInstructions(
|
||||||
|
endIndex + 1,
|
||||||
|
"""
|
||||||
|
move-result v0
|
||||||
|
return v0
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
} ?: return StoryboardThumbnailFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
|
||||||
|
// Seekbar thumbnail now show up but are always a blank image.
|
||||||
|
// Additional changes are needed to force the client to generate the thumbnails (assuming it's possible),
|
||||||
|
// but for now hide the empty thumbnail.
|
||||||
|
ScrubbedPreviewLayoutFingerprint.result?.apply {
|
||||||
|
val endIndex = scanResult.patternScanResult!!.endIndex
|
||||||
|
mutableMethod.apply {
|
||||||
|
val imageViewFieldName = getInstruction<ReferenceInstruction>(endIndex).reference
|
||||||
|
addInstructions(
|
||||||
|
implementation!!.instructions.lastIndex,
|
||||||
|
"""
|
||||||
|
iget-object v0, p0, $imageViewFieldName # copy imageview field to a register
|
||||||
|
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->seekbarImageViewCreated(Landroid/widget/ImageView;)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return ScrubbedPreviewLayoutFingerprint.toErrorResult()
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package app.revanced.patches.youtube.misc.fix.playback.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
|
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||||
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.*
|
||||||
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
|
|
||||||
|
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||||
|
class SpoofSignatureVerificationResourcePatch : ResourcePatch {
|
||||||
|
|
||||||
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
|
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"
|
||||||
|
+ "• Seekbar thumbnails are hidden\\n"
|
||||||
|
+ "• Downloading videos may not work"),
|
||||||
|
StringResource("revanced_spoof_signature_verification_summary_off", "App signature not spoofed"),
|
||||||
|
StringResource("revanced_spoof_signature_verification_user_dialog_message",
|
||||||
|
"Turning off this setting may cause playback issues.")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
scrubbedPreviewThumbnailResourceId = ResourceMappingPatch.resourceMappings.single {
|
||||||
|
it.type == "id" && it.name == "thumbnail"
|
||||||
|
}.id
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
var scrubbedPreviewThumbnailResourceId: Long = -1
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue