Skip to content

Instantly share code, notes, and snippets.

@akaleeroy
Last active April 21, 2025 22:19
Show Gist options
  • Save akaleeroy/ba29b44968ef3921404241c1f1fdc2d1 to your computer and use it in GitHub Desktop.
Save akaleeroy/ba29b44968ef3921404241c1f1fdc2d1 to your computer and use it in GitHub Desktop.
Use Tor Browser as plain Firefox Browser

Use Tor Browser as plain Firefox Browser

Without routing traffic through the Tor network. Useful in testing for Web development, to not install another Firefox if you already have Tor.

Answer

This script applies the following settings. You can set these in about:config

extensions.torbutton.test_enabled = false
extensions.torlauncher.start_tor = false
network.dns.disabled = false
network.proxy.type = 0

How it works

You can customize the Tor Browser using a Firefox policies.json file. Its location is defined at the top of the script

  • Windows using Chocolatey: "${ChocolateyInstall}/lib/tor-browser/tools/tor-browser/Browser/distribution"
  • Mac OS: Firefox.app/Contents/Resources/distribution
  • Linux: <firefox installation directory>/distribution or system-wide /etc/firefox/policies

Once the correct policies directory is set the script writes the settings for using Tor Browser as a plain Firefox installation, using jq. The script starts the browser, waits for it to close, then restores the original policy settings.

It is useful to create a shortcut, Firefox from Tor for example, that invokes this script. For example, on Windows using Git Bash the shortcut's Target field could be:

"C:\Program Files\Git\git-bash.exe" --hide "D:\Config\Programs\Tor Browser\tor-as-firefox.sh"

To further signal that the window is not a Tor Browser window you can go to about:profiles, open Root Directory and place /chrome/userContent.css. The script also temporarily enables this stylesheet by setting toolkit.legacyUserProfileCustomizations.stylesheets to true.

Dependencies

jq

Reference

Customize Firefox using policies.json | Firefox for Enterprise Help

Notes

Creating a user.js file did not work. But here are the same settings in that format:

// User.js user preferences file to make Tor Browser run as simple Firefox

user_pref("extensions.torbutton.test_enabled", false)
user_pref("extensions.torlauncher.start_tor", false)
user_pref("network.dns.disabled", false)
user_pref("network.proxy.type", 0)
#!/usr/bin/env bash
# EDIT THIS for you installation. This is for when Tor Browser was installed on Windows using Chocolatey
FIREFOX_DIR="${ChocolateyInstall}/lib/tor-browser/tools/tor-browser/Browser"
# Disable history recording for this script execution
set +o history
# Check for jq availability
command -v jq >/dev/null 2>&1 || {
echo -e "\033[0;31mError: Script requires jq, please install it.\033[0m" >&2
echo -e "See https://jqlang.org" >&2
exit 1
}
CONFIGS=$(cat << eof
{
"policies": {
"Preferences": {
"extensions.torbutton.test_enabled": { "Value": false },
"extensions.torlauncher.start_tor": { "Value": false },
"network.dns.disabled": { "Value": false },
"network.proxy.type": { "Value": 0 },
"toolkit.legacyUserProfileCustomizations.stylesheets": { "Value": true }
}
}
}
eof
)
cleanup() {
echo "Restoring defaults..."
cd "${FIREFOX_DIR}/distribution"
cp policies.json firefox.json.bak
jq --argjson configs "$CONFIGS" '
($configs | .policies.Preferences | keys) as $keys
| del(.policies.Preferences[$keys[]])
' policies.json > tmp.json && mv tmp.json policies.json
exit 1
}
# Once the process terminates, restore default policy
# Set up a trap to call the cleanup function on EXIT, SIGINT, or SIGTERM
trap cleanup EXIT SIGINT SIGTERM
# Navigate to Tor Browser installation directory
cd "${FIREFOX_DIR}/distribution"
# Write Tor-as-plain-Firefox browser configs
[[ -f policies.json ]] && \
jq --argjson configs "$CONFIGS" '. * $configs' policies.json > tmp.json && \
mv tmp.json policies.json || \
printf '%s\n' "$CONFIGS" > policies.json
# Launch Tor Browser’s Firefox executable in the background
"${FIREFOX_DIR}/firefox" &
# Capture the PID of the launched process
FIREFOX_PID=$!
# Wait for the process to terminate
wait $FIREFOX_PID
/* First set about:config?filter=toolkit.legacyUserProfileCustomizations.stylesheets to true */
/* https://stackoverflow.com/questions/57521737/how-to-make-aboutnewtab-new-tab-page-in-dark-mode-while-dark-mode-activated-i */
@-moz-document url-prefix(about:tor), url-prefix(about:newtab), url-prefix(about:home) {
body.onion-pattern-background {
background: var(--in-content-primary-button-text-color) !important;
}
#tor-browser-logo,
#tor-browser-home-heading-stable {
display: none !important
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment