From e84b7b328ea48e86d240d38cf83aa960f87d6902 Mon Sep 17 00:00:00 2001 From: oSumAtrIX <johan.melkonyan1@web.de> Date: Sun, 12 Nov 2023 01:27:19 +0100 Subject: [PATCH] feat(YouTube): Add `Remove tracking query parameter` patch Implementation references taken from github.com/inotia00/revanced-patches/commit/4037d9c85b7e37f8635f8fdcc1efea85dcddb5e2. --- .../RemoveTrackingQueryParameterPatch.java | 16 ++++++++++++++++ .../integrations/settings/SettingsEnum.java | 1 + 2 files changed, 17 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/patches/RemoveTrackingQueryParameterPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/RemoveTrackingQueryParameterPatch.java b/app/src/main/java/app/revanced/integrations/patches/RemoveTrackingQueryParameterPatch.java new file mode 100644 index 00000000..4910f586 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/RemoveTrackingQueryParameterPatch.java @@ -0,0 +1,16 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public final class RemoveTrackingQueryParameterPatch { + private static final String NEW_TRACKING_PARAMETER_REGEX = ".si=.+"; + private static final String OLD_TRACKING_PARAMETER_REGEX = ".feature=.+"; + + public static String sanitize(String url) { + if (!SettingsEnum.REMOVE_TRACKING_QUERY_PARAMETER.getBoolean()) return url; + + return url + .replaceAll(NEW_TRACKING_PARAMETER_REGEX, "") + .replaceAll(OLD_TRACKING_PARAMETER_REGEX, ""); + } +} diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index 105bea54..937fa02a 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -190,6 +190,7 @@ public enum SettingsEnum { ANNOUNCEMENTS("revanced_announcements", BOOLEAN, TRUE), ANNOUNCEMENT_CONSUMER("revanced_announcement_consumer", STRING, ""), ANNOUNCEMENT_LAST_HASH("revanced_announcement_last_hash", STRING, ""), + REMOVE_TRACKING_QUERY_PARAMETER("revanced_remove_tracking_query_parameter", BOOLEAN, TRUE), // Swipe controls SWIPE_BRIGHTNESS("revanced_swipe_brightness", BOOLEAN, TRUE),