diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ProtobufSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ProtobufSpoofPatch.kt
index c4a5bb523..586565030 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ProtobufSpoofPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ProtobufSpoofPatch.kt
@@ -7,19 +7,21 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.addInstructions
-import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
+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.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
+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])
@YouTubeCompatibility
@Version("0.0.1")
class ProtobufSpoofPatch : BytecodePatch(
@@ -33,30 +35,28 @@ class ProtobufSpoofPatch : BytecodePatch(
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
) {
- // Issue with sound always playing when spoofing protobuf in feed
- // https://github.com/inotia00/ReVanced_Extended/issues/471
- // To fix this issue, protobuf spoof should only be done at video player
-
- // The length of protobuf in video player is between 12 and 14
- // The length of protobuf in the feed is between 16 and 18
- // Therefore, protobuf spoof should only be done when protobuf length is less than 16
val protobufParam = 3
- val protobufParameter = "CgIQBg%3D%3D" /* Protobuf Parameter of X-Goog-Visitor-Id */
addInstructions(
0,
"""
- invoke-virtual { p$protobufParam }, Ljava/lang/String;->length()I
- move-result v0
- const/16 v1, 0x10
- if-ge v0, v1, :not_spoof
- const-string p$protobufParam, "$protobufParameter"
- """,
- listOf(ExternalLabel("not_spoof", instruction(0)))
+ invoke-static {p$protobufParam}, $MISC_PATH/ProtobufSpoofPatch;->getProtobufOverride(Ljava/lang/String;)Ljava/lang/String;
+ move-result-object p$protobufParam
+ """
)
}
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
+ /*
+ * Add settings
+ */
+ SettingsPatch.addPreference(
+ arrayOf(
+ "SETTINGS: ENABLE_PROTOBUF_SPOOF"
+ )
+ )
+ SettingsPatch.updatePatchStatus("protobuf-spoof")
+
return PatchResultSuccess()
}
}
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 3b4d4475d..0974e10b5 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -208,6 +208,8 @@ Is it ready to submit?"
Enable open links directly
Tricks the dpi to use some phone layouts
Enable phone layout
+ Spoofs the protobuf to prevent playback issues
+ Enable protobuf spoof
Press-to-swipe is disabled
Press-to-swipe is enabled
Enable press-to-swipe gesture
@@ -515,6 +517,9 @@ Since these setting is quite outdated, it may not be valid"
Changing default Wi-Fi quality to:
Changing default speed to:
Seekbar layout
+ Spoof to general video
+ Spoof to shorts video
+ Select protobuf to spoof
SponsorBlock related settings
Swipe controls
The amount of threshold for swipe to occur
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index 84b0e88e9..aa7198d03 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -373,6 +373,10 @@
+
+
@@ -469,6 +473,7 @@
+