feat(youtube): open-links-directly patch (#201)

This commit is contained in:
johnconner122 2022-11-10 01:42:24 +05:00 committed by GitHub
parent 302b57d8f0
commit c3c16563ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,18 @@
package app.revanced.integrations.patches;
import java.net.URLDecoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import app.revanced.integrations.settings.SettingsEnum;
public class OpenLinksDirectlyPatch {
public static String parseRedirectUri(String uri) {
if (SettingsEnum.OPEN_LINKS_DIRECTLY.getBoolean()) {
Matcher matcher = Pattern.compile("&q=(http.+?)&v=").matcher(uri);
return matcher.find() ? URLDecoder.decode(matcher.group(1)) : uri;
}
return uri;
}
}

View File

@ -87,6 +87,7 @@ public enum SettingsEnum {
USE_HDR_AUTO_BRIGHTNESS("revanced_pref_hdr_autobrightness", true, ReturnType.BOOLEAN),
TAP_SEEKING_ENABLED("revanced_enable_tap_seeking", true, ReturnType.BOOLEAN),
ENABLE_MINIMIZED_PLAYBACK("revanced_enable_minimized_playback", true, ReturnType.BOOLEAN),
OPEN_LINKS_DIRECTLY("revanced_uri_redirect", true, ReturnType.BOOLEAN, true),
// Swipe controls
ENABLE_SWIPE_BRIGHTNESS("revanced_enable_swipe_brightness", true, ReturnType.BOOLEAN),