feat(YouTube): Add Bypass URL redirects patch

This commit is contained in:
oSumAtrIX 2023-09-28 04:47:40 +02:00
parent 444b80026d
commit 91096532ee
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package app.revanced.integrations.patches;
import android.net.Uri;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
public class BypassURLRedirectsPatch {
private static final String YOUTUBE_REDIRECT_PATH = "/redirect";
/**
* Convert the YouTube redirect URI string to the redirect query URI.
*
* @param uri The YouTube redirect URI string.
* @return The redirect query URI.
*/
public static Uri parseRedirectUri(String uri) {
final var parsed = Uri.parse(uri);
if (SettingsEnum.BYPASS_URL_REDIRECTS.getBoolean() && parsed.getPath().equals(YOUTUBE_REDIRECT_PATH)) {
var query = Uri.parse(Uri.decode(parsed.getQueryParameter("q")));
LogHelper.printDebug(() -> "Bypassing YouTube redirect URI: " + query);
return query;
}
return parsed;
}
}

View File

@ -169,6 +169,7 @@ public enum SettingsEnum {
"revanced_spoof_signature_verification_enabled_user_dialog_message"),
SPOOF_SIGNATURE_IN_FEED("revanced_spoof_signature_in_feed_enabled", BOOLEAN, FALSE, false,
parents(SPOOF_SIGNATURE)),
BYPASS_URL_REDIRECTS("revanced_bypass_url_redirects", BOOLEAN, TRUE),
// Swipe controls
SWIPE_BRIGHTNESS("revanced_swipe_brightness", BOOLEAN, TRUE),