This script allows users to block or whitelist specific URLs or paths in Firefox by modifying the policies.json file.
Unlike traditional website blockers, it does not block entire domains by default, giving users fine-grained control over what is restricted.
- Block specific URLs or paths in Firefox
- Add exceptions (whitelist URLs or paths)
- Prevent duplicate entries
- Works on a per-user basis (
/usr/lib/firefox/distribution/policies.json) - Can be adapted for system-wide policies
This script requires jq, a lightweight JSON processor. Install it with:
sudo apt install jq # Debian/Ubuntu
sudo dnf install jq # Fedora
brew install jq # macOS- Save the script as
fireblockin/usr/local/bin/:sudo cp fireblock.sh /usr/local/bin/fireblock sudo chmod +x /usr/local/bin/fireblock
- Ensure
/usr/local/bin/is in your$PATH(it usually is by default):export PATH="/usr/local/bin:$PATH"
To block specific pages or paths on a website, run:
fireblock example.com another-site.com/specific-pageThis adds only the specified URLs or paths to Firefox's blocked list.
If you want to block all sub-paths or an entire domain, add the * character at the end:
fireblock example.com/* another.com/pages/*This ensures all pages under example.com are blocked and all sub-pages in another.com/pages are blocked.
To allow specific sites or paths while others are blocked, use the -e flag:
fireblock -e example.com/specific-pageThis adds example.com/specific-page to the exceptions list.
The policy file is located at:
/usr/lib/firefox/distribution/policies.jsonFor system-wide policies (root access required):
/etc/firefox/policies/policies.json- Restart Firefox for changes to take effect.
- The script ensures no duplicate entries are added.
- For enterprise or system-wide settings, update the
POLICY_FILEvariable in the script accordingly.