diff --git a/integrations/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java b/integrations/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java index 874781f59..9edd455fa 100644 --- a/integrations/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java +++ b/integrations/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java @@ -1,16 +1,20 @@ package app.revanced.integrations.patches; -import static app.revanced.integrations.utils.ReVancedUtils.containsAny; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; - import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.shared.PlayerType; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; +import static app.revanced.integrations.utils.ReVancedUtils.containsAny; + public class SpoofSignatureVerificationPatch { + /** + * Enable/disable all workarounds that are required due to signature spoofing. + */ + private static final boolean WORKAROUND = true; + /** * Protobuf parameters used for autoplay in scrim. * Prepend this parameter to mute video playback (for autoplay in feed) @@ -18,10 +22,12 @@ public class SpoofSignatureVerificationPatch { private static final String PROTOBUF_PARAMETER_SCRIM = "SAFgAXgB"; /** - * Protobuf parameter of shorts and YouTube stories. + * Protobuf parameter also used by + * yt-dlp + *
* Known issue: captions are positioned on upper area in the player. */ - private static final String PROTOBUF_PARAMETER_SHORTS = "8AEB"; // "8AEByAMTuAQP" + private static final String PROTOBUF_PLAYER_PARAMS = "CgIQBg=="; /** * Target Protobuf parameters. @@ -66,17 +72,18 @@ public class SpoofSignatureVerificationPatch { LogHelper.printDebug(() -> "Original protobuf parameter value: " + originalValue); - // Video is Short or Story. - var isPlayingShorts = originalValue.contains(PROTOBUF_PARAMETER_SHORTS); - if (isPlayingShorts) return originalValue; + if (!WORKAROUND) return PROTOBUF_PLAYER_PARAMS; + + var isPlayingVideo = originalValue.contains(PROTOBUF_PLAYER_PARAMS); + if (isPlayingVideo) return originalValue; boolean isPlayingFeed = containsAny(originalValue, PROTOBUF_PARAMETER_TARGETS) && PlayerType.getCurrent() == PlayerType.INLINE_MINIMAL; if (isPlayingFeed) { // Videos in feed won't autoplay with sound. - return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PARAMETER_SHORTS; + return PROTOBUF_PARAMETER_SCRIM + PROTOBUF_PLAYER_PARAMS; } else { // Spoof the parameter to prevent playback issues. - return PROTOBUF_PARAMETER_SHORTS; + return PROTOBUF_PLAYER_PARAMS; } } catch (Exception ex) { LogHelper.printException(() -> "overrideProtobufParameter failure", ex); @@ -143,6 +150,10 @@ public class SpoofSignatureVerificationPatch { } } + if (!WORKAROUND) { + return new int[]{ap, ah, av}; + } + // Videos with custom captions that specify screen positions appear to always have correct screen positions (even with spoofing). // But for auto generated and most other captions, the spoof incorrectly gives various default Shorts caption settings. // Check for these known default shorts captions parameters, and replace with the known correct values.