if (url.contains("&fbclid=")) {
url = url.substring(0, url.indexOf("&fbclid="));
}
+
+ // Remove `?fbadid=`.
+ if (url.contains("?fbadid=")) {
+ url = url.substring(0, url.indexOf("?fbadid="));
+ }
+
+ // Remove `&fbadid=`.
+ if (url.contains("&fbadid=")) {
+ url = url.substring(0, url.indexOf("&fbadid="));
+ }
}
// Sanitize Twitter AMP redirects.
tabTitleTextView.setText(R.string.new_tab);
}
} else { // The WebView has loaded a webpage.
- // Display the final URL. Getting the URL from the WebView instead of using the one provided by `onPageFinished()` makes websites like YouTube function correctly.
- urlEditText.setText(currentUrl);
+ // Update the URL edit text if it is not currently being edited.
+ if (!urlEditText.hasFocus()) {
+ // Sanitize the current URL. This removes unwanted URL elements that were added by redirects, so that they won't be included if the URL is shared.
+ String sanitizedUrl = sanitizeUrl(currentUrl);
+
+ // Display the final URL. Getting the URL from the WebView instead of using the one provided by `onPageFinished()` makes websites like YouTube function correctly.
+ urlEditText.setText(sanitizedUrl);
- // Apply text highlighting to the URL.
- highlightUrlText();
+ // Apply text highlighting to the URL.
+ highlightUrlText();
+ }
// Only populate the title text view if the tab has been fully created.
if (tab != null) {
<string name="block_all_third_party_requests_summary">Blocking all third-party requests increases privacy, but it breaks many websites.</string>
<string name="url_modification">URL Modification</string>
<string name="google_analytics">Google Analytics</string>
- <string name="google_analytics_summary">Remove “?utm_” or “&utm_” and anything after it from URLs.</string>
+ <string name="google_analytics_summary">Remove “?utm_” and “&utm_” and anything after them from URLs.</string>
<string name="facebook_click_ids">Facebook Click IDs</string>
- <string name="facebook_click_ids_summary">Remove “?fbclid=” or “&fbclid=” and anything after it from URLs.</string>
+ <string name="facebook_click_ids_summary">Remove “?fbclid=”, “&fbclid=”, “?fbadid=”, and “&fbadid=” and anything after them from URLs.</string>
<string name="twitter_amp_redirects">Twitter AMP redirects</string>
<string name="twitter_amp_redirects_summary">Remove “?amp=1” and anything after it from URLs.</string>
<string name="tor">Tor</string>