]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Add option to remove Facebook Click IDs from URLs. https://redmine.stoutner.com...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index 7900b066e500ef7217f19ed7b73762a2bbbd3925..aa0914538588807ec2302600be411041fbc09c0a 100644 (file)
@@ -281,6 +281,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
     // The URL sanitizers are set in `applyAppSettings()` and used in `sanitizeUrl()`.
     private boolean sanitizeGoogleAnalytics;
+    private boolean sanitizeFacebookClickIds;
 
     // The download strings are used in `onCreate()`, `onRequestPermissionResult()` and `initializeWebView()`.
     private String downloadUrl;
@@ -3060,6 +3061,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false);
         boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false);
         sanitizeGoogleAnalytics = sharedPreferences.getBoolean("google_analytics", true);
+        sanitizeFacebookClickIds = sharedPreferences.getBoolean("facebook_click_ids", true);
         proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
         fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("full_screen_browsing_mode", false);
         hideAppBar = sharedPreferences.getBoolean("hide_app_bar", true);
@@ -3980,6 +3982,19 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             }
         }
 
+        // Sanitize Facebook Click IDs.
+        if (sanitizeFacebookClickIds) {
+            // Remove `?fbclid=`.
+            if (url.contains("?fbclid=")) {
+                url = url.substring(0, url.indexOf("?fbclid="));
+            }
+
+            // Remove &fbclid=`.
+            if (url.contains("&fbclid=")) {
+                url = url.substring(0, url.indexOf("&fbclid="));
+            }
+        }
+
         // Return the sanitized URL.
         return url;
     }