diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/BadResponseFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/BadResponseFingerprint.kt new file mode 100644 index 000000000..2ed46500f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/fingerprints/BadResponseFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.youtube.misc.protobufpoof.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object BadResponseFingerprint : MethodFingerprint( + opcodes = listOf( + Opcode.CONST_16 + ), + strings = listOf("Response code: ") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt index add13a129..2d2b5b879 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/protobufpoof/patch/ProtobufSpoofPatch.kt @@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker +import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -14,21 +15,31 @@ 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.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.protobufpoof.fingerprints.ProtobufParameterBuilderFingerprint +import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch +import app.revanced.patches.youtube.misc.protobufpoof.fingerprints.* import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH @Patch @Name("protobuf-spoof") @Description("Spoofs the protobuf to prevent playback issues.") -@DependsOn([SettingsPatch::class]) +@DependsOn( + [ + PlayerTypeHookPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") class ProtobufSpoofPatch : BytecodePatch( - listOf(ProtobufParameterBuilderFingerprint) + listOf( + BadResponseFingerprint, + ProtobufParameterBuilderFingerprint + ) ) { override fun execute(context: BytecodeContext): PatchResult { + // hook parameter ProtobufParameterBuilderFingerprint.result?.let { with (context .toMethodWalker(it.method) @@ -47,6 +58,12 @@ class ProtobufSpoofPatch : BytecodePatch( } } ?: return ProtobufParameterBuilderFingerprint.toErrorResult() + // hook video playback result + BadResponseFingerprint.result?.mutableMethod?.addInstruction( + 0, + "invoke-static {}, $MISC_PATH/ProtobufSpoofPatch;->switchProtobufSpoof()V" + ) ?: return BadResponseFingerprint.toErrorResult() + /* * Add settings */ diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 60682ee68..046a43229 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -511,6 +511,7 @@ Please do not report any issues you encounter while using this feature."Information about applied patches Player flyout panel Player + Spoofing protobuf to prevent playback issues "As this is still an experimental feature, there may be other unknown issues. Are you sure you want to continue though?" "Tricks the dpi to change some layouts to phone layouts.