Enable Firefox tracking protection
Overview
This script improves your privacy on Linux.
These changes use Linux system commands to update your settings.
Firefox provides an option for Enhanced Tracking Protection 1, which blocks trackers that gather information about your browsing behavior without disrupting site functionality 1. This feature also includes protections against harmful scripts such as malware that drain your battery 1.
This script enables the privacy.resistFingerprinting
preference,
activating anti-fingerprinting 1.
Beyond privacy advantages; enabling tracking protection may reduce load time by 44% 3.
Note: If you are already using an ad blocker with the correct lists, tracking protection might be redundant.
This script uses Bash (Shell script) scripting language.
This script is recommended for all users. It helps to improve privacy without affecting stability.
Implementation Details
-
Language: bash
-
Required Privileges: Root/sudo access
-
Compatibility: Linux only
-
Reversibility: Can be undone using provided revert script
Explore Categories
- Harden Firefox privacy
- Configure Firefox
- Configure programs
This action belongs to Harden Firefox privacy category. The following are privacy-focused tweaks to prevent browser fingerprinting and tracking. See also: What is browser fingerprinting? | AmIUnique.org Read more on category page ▶
This action belongs to Configure Firefox category. Mozilla Firefox, colloquially known as Firefox, is a free and open-source web browser created by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. By default, Firefox collects telemetry data and has other features that gather information about your downloaded files and browsed... Read more on category page ▶
This action belongs to Configure programs category. These scripts configure third-party applications installed on Linux distributions to harden their security and privacy to protect your data. They scripts differ from OS level configurations as they configure applications that are not typically native to Linux distributions, i.e., not included in... Read more on category page ▶
Apply now
Choose one of three ways to apply:
- Automatically via privacy.sexy: The easiest and safest option.
- Manually by downloading: Requires downloading a file.
- Manually by copying: Advanced flexibility.
Alternative 1. Apply with Privacy.sexy
privacy.sexy is free and open-source application that lets securely apply this action easily.
You can fully restore this action (revert back to the original behavior) using the application.
privacy.sexy instructions
- Open or download the desktop application
- Search for the script name:
Enable Firefox tracking protection
. - Check the script by clicking on the checkbox.
- Click on Run button at the bottom of the page.
Alternative 2. Download
This script is irreversible, meaning there is no straightforward method to restore changes once applied. Exercise caution before running, restoring it may not be possible.
-
Download the script file by clicking on the button below:
-
Run the script file by clicking on it.
Download revert script
This file restores your system to its original state, before this script is applied.
Alternative 3. Copy
This is for advanced users. Consider automatically applying or downloading the script for simpler way.
-
Open Terminal
-
Copy the following code:
pref_name='privacy.trackingprotection.enabled'
pref_value='true'
echo "Setting preference \"$pref_name\" to \"$pref_value\"."
declare -a profile_paths=(
~/.mozilla/firefox/*/
~/.var/app/org.mozilla.firefox/.mozilla/firefox/*/
~/snap/firefox/common/.mozilla/firefox/*/
)
declare -i total_profiles_found=0
for profile_dir in "${profile_paths[@]}"; do
if [ ! -d "$profile_dir" ]; then
continue
fi
if [[ ! "$(basename "$profile_dir")" =~ ^[a-z0-9]{8}\..+ ]]; then
continue # Not a profile folder
fi
((total_profiles_found++))
user_js_file="${profile_dir}user.js"
echo "$user_js_file:"
if [ ! -f "$user_js_file" ]; then
touch "$user_js_file"
echo $'\t''Created new user.js file'
fi
pref_start="user_pref(\"$pref_name\","
pref_line="user_pref(\"$pref_name\", $pref_value);"
if ! grep --quiet "^$pref_start" "${user_js_file}"; then
echo -n $'\n'"$pref_line" >> "$user_js_file"
echo $'\t'"Successfully added a new preference in $user_js_file."
elif grep --quiet "^$pref_line$" "$user_js_file"; then
echo $'\t'"Skipping, preference is already set as expected in $user_js_file."
else
sed --in-place "/^$pref_start/c\\$pref_line" "$user_js_file"
echo $'\t'"Successfully replaced the existing incorrect preference in $user_js_file."
fi
done
if [ "$total_profiles_found" -eq 0 ]; then
echo 'No profile folders are found, no changes are made.'
else
echo "Successfully verified preferences in $total_profiles_found profiles."
fi
- Paste the code into terminal.
- Press Enter to apply the code.
Some scripts requires restarting your computer to take affect.
Copy restore code
Copy and run the following code to restore changes:
pref_name='privacy.trackingprotection.enabled'
pref_value='true'
echo "Reverting preference: \"$pref_name\" to its default."
if command -v 'ps' &> /dev/null && ps aux | grep -i "[f]irefox" > /dev/null; then
>&2 echo -e "\e[33mWarning: Firefox is currently running. Please close Firefox before executing the revert script to ensure changes are applied effectively.\e[0m"
fi
declare -a files_to_modify=('prefs.js' 'user.js')
declare -a profile_paths=(
~/.mozilla/firefox/*/
~/.var/app/org.mozilla.firefox/.mozilla/firefox/*/
~/snap/firefox/common/.mozilla/firefox/*/
)
declare -i total_profiles_found=0
for profile_dir in "${profile_paths[@]}"; do
if [ ! -d "$profile_dir" ]; then
continue
fi
if [[ ! "$(basename "$profile_dir")" =~ ^[a-z0-9]{8}\..+ ]]; then
continue # Not a profile folder
fi
((total_profiles_found++))
for file_to_modify in "${files_to_modify[@]}"; do
config_file_path="${profile_dir}${file_to_modify}"
if [ ! -f "$config_file_path" ]; then
continue
fi
echo "$config_file_path:"
pref_start="user_pref(\"$pref_name\","
pref_line="user_pref(\"$pref_name\", $pref_value);"
if ! grep --quiet "^$pref_start" "${config_file_path}"; then
echo $'\t''Skipping, preference was not configured before.'
elif grep --quiet "^$pref_line$" "${config_file_path}"; then
sed --in-place "/^$pref_line/d" "$config_file_path"
echo $'\t''Successfully reverted preference to default.'
if ! grep --quiet '[^[:space:]]' "$config_file_path"; then
rm "$config_file_path"
echo $'\t'"Removed the file as it became empty."
fi
else
echo $'\t''Skipping, the preference has value that is not configured by privacy.sexy.'
fi
done
done
if [ "$total_profiles_found" -eq 0 ]; then
echo 'No reversion was necessary.'
else
echo "Successfully verified preferences in $total_profiles_found profiles."
fi
Support
This website relies on your support.
Your donation helps keep the project alive and improves its content ❤️.
Share this page: