Skip to content

Instantly share code, notes, and snippets.

@yokoffing
Last active October 22, 2024 16:36
Show Gist options
  • Save yokoffing/e637a8edc8bbab4b2f99238ceb7ad081 to your computer and use it in GitHub Desktop.
Save yokoffing/e637a8edc8bbab4b2f99238ceb7ad081 to your computer and use it in GitHub Desktop.
/*
Custom Firefox settings for enhanced privacy, security, and performance
Format credit: Jeremy Neale (remy1)
Betterfox 2.0
Version: 132
Installation:
-> Go to about:support in Firefox URL and open the profile directory
-> Place this user.js file in this directory and restart Firefox
*/
/**
* Choose which features to enable/disable
* Be sure to review the optional categories
*/
var generalPreferences = true;
var disableTelemetry = true;
var trackingProtection = true;
var securityEnhancements = true;
var performanceOptimizations = true;
// OPTIONAL - strict tracking protection and related settings
var advancedPrivacy = false;
// OPTIONAL - tighter security
var advancedSecurity = false;
// OPTIONAL - GPU and other performance settings
var advancedPerformance = false;
// OPTIONAL - adjust scrolling on Windows and Linux
var betterScrolling = false;
// OPTIONAL - space for your custom overrides
var customOverrides = false;
function main() {
if (generalPreferences) {
applyGeneralPreferences();
}
if (disableTelemetry) {
applyDisableTelemetry();
}
if (trackingProtection) {
applyTrackingProtection();
}
if (securityEnhancements) {
applySecurityEnhancements();
}
if (performanceOptimizations) {
applyPerformance();
}
if (advancedPrivacy) {
applyAdvancedPrivacy();
}
if (advancedSecurity) {
applyAdvancedSecurity();
}
if (advancedPerformance) {
applyAdvancedPerformance();
}
if (betterScrolling) {
applyBetterScrolling();
}
if (customOverrides) {
applyOverrides();
}
}
// -------------------------------------------------------------------------------
function applyGeneralPreferences()
{
user_pref("browser.privatebrowsing.vpnpromourl", "");
user_pref("extensions.getAddons.showPane", false);
user_pref("extensions.htmlaboutaddons.recommendations.enabled", false);
user_pref("browser.discovery.enabled", false);
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons", false);
user_pref("browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", false);
user_pref("browser.preferences.moreFromMozilla", false);
user_pref("browser.aboutConfig.showWarning", false);
user_pref("browser.aboutwelcome.enabled", false);
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref("browser.compactmode.show", true);
user_pref("full-screen-api.warning.timeout", 0);
user_pref("browser.bookmarks.openInTabClosesMenu", false); // false on macOS
user_pref("browser.tabs.loadBookmarksInTabs", true); // force bookmarks to open in a new tab, not the current tab
user_pref("findbar.highlightAll", true);
user_pref("browser.startup.homepage_override.mstone", "ignore"); // What's New page after updates; master switch
user_pref("view_source.wrap_long_lines", true); // wrap source lines
user_pref("devtools.debugger.ui.editor-wrapping", true); // wrap lines in devtools
user_pref("layout.word_select.eat_space_to_next_word", false); // do not select the space next to a word when selecting a word
user_pref("browser.search.update", false); // do not update opensearch engines
// hide weather and top site shortcuts on New Tab
user_pref("browser.newtabpage.activity-stream.showWeather", false);
user_pref("browser.newtabpage.activity-stream.feeds.topsites", false);
// do not show Pocket on New Tab
user_pref("extensions.pocket.enabled", false);
user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);
// URL bar enhancements
user_pref("browser.search.separatePrivateDefault.ui.enabled", true);
user_pref("browser.urlbar.update2.engineAliasRefresh", true);
user_pref("browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar", false); // use NTP search box for search
user_pref("browser.urlbar.trimHttps", true);
user_pref("browser.urlbar.untrimOnUserInteraction.featureGate", true);
user_pref("browser.urlbar.quicksuggest.enabled", false);
user_pref("browser.urlbar.suggest.quicksuggest.nonsponsored", false);
user_pref("browser.urlbar.suggest.quicksuggest.sponsored", false);
user_pref("browser.urlbar.groupLabels.enabled", false);
user_pref("browser.formfill.enable", false); // Remember search and form history
user_pref("browser.urlbar.suggest.calculator", true);
user_pref("browser.urlbar.unitConversion.enabled", true);
user_pref("browser.urlbar.trending.featureGate", false);
}
// -------------------------------------------------------------------------------
function applyDisableTelemetry()
{
// telemetry
user_pref("datareporting.policy.dataSubmissionEnabled", false);
user_pref("datareporting.healthreport.uploadEnabled", false);
user_pref("toolkit.telemetry.unified", false);
user_pref("toolkit.telemetry.enabled", false);
user_pref("toolkit.telemetry.server", "data:,");
user_pref("toolkit.telemetry.archive.enabled", false);
user_pref("toolkit.telemetry.newProfilePing.enabled", false);
user_pref("toolkit.telemetry.shutdownPingSender.enabled", false);
user_pref("toolkit.telemetry.updatePing.enabled", false);
user_pref("toolkit.telemetry.bhrPing.enabled", false);
user_pref("toolkit.telemetry.firstShutdownPing.enabled", false);
user_pref("toolkit.telemetry.coverage.opt-out", true);
user_pref("toolkit.coverage.opt-out", true);
user_pref("toolkit.coverage.endpoint.base", "");
user_pref("browser.newtabpage.activity-stream.feeds.telemetry", false);
user_pref("browser.newtabpage.activity-stream.telemetry", false);
// experiments
user_pref("app.shield.optoutstudies.enabled", false);
user_pref("app.normandy.enabled", false);
user_pref("app.normandy.api_url", "");
user_pref("breakpad.reportURL", "");
// crash reports
user_pref("browser.tabs.crashReporting.sendReport", false);
user_pref("browser.crashReports.unsubmittedCheck.autoSubmit2", false);
user_pref("browser.crashReports.unsubmittedCheck.enabled", false); // true by default on NIGHTLY
// detection
user_pref("captivedetect.canonicalURL", "");
user_pref("network.captive-portal-service.enabled", false);
user_pref("network.connectivity-service.enabled", false);
}
// -------------------------------------------------------------------------------
function applyTrackingProtection()
{
// prevent what you type from going to Google by default
user_pref("browser.search.suggest.enabled", false);
// disable certain permissions that are annoying
user_pref("permissions.default.desktop-notification", 2); // notifications
user_pref("permissions.default.geo", 2); // location
// trim referers
user_pref("network.http.referer.XOriginTrimmingPolicy", 1);
// disable speculative connections
// not very helpful if you use an adblocker
user_pref("network.dns.disablePrefetch", true);
user_pref("network.dns.disablePrefetchFromHTTPS", true);
user_pref("network.prefetch-next", false);
user_pref("network.predictor.enabled", false);
user_pref("network.predictor.enable-prefetch", false);
}
// -------------------------------------------------------------------------------
function applySecurityEnhancements()
{
user_pref("browser.uitour.enabled", false);
user_pref("security.OCSP.enabled", 0);
user_pref("security.remote_settings.crlite_filters.enabled", true);
user_pref("security.pki.crlite_mode", 2);
user_pref("security.tls.enable_0rtt_data", false);
user_pref("dom.security.https_first", true);
user_pref("network.auth.subresource-http-auth-allow", 1);
user_pref("signon.formlessCapture.enabled", false);
user_pref("network.IDN_show_punycode", true);
user_pref("extensions.enabledScopes", 5);
user_pref("browser.safebrowsing.downloads.remote.enabled", false);
user_pref("browser.download.start_downloads_in_tmp_dir", true);
user_pref("browser.helperApps.deleteTempFileOnExit", true);
}
// -------------------------------------------------------------------------------
function applyPerformance()
{
user_pref("browser.sessionstore.interval", 60000); // save session every 1 minute in case of crash
user_pref("network.http.max-connections", 1800);
user_pref("network.http.max-persistent-connections-per-server", 10);
user_pref("network.http.max-urgent-start-excessive-connections-per-host", 5);
user_pref("network.http.pacing.requests.enabled", false);
// cache optimizations
user_pref("browser.cache.disk.enable", false);
user_pref("network.http.rcwn.enabled", false);
user_pref("browser.privatebrowsing.forceMediaMemoryCache", true);
user_pref("media.memory_cache_max_size", 65536);
}
// -------------------------------------------------------------------------------
/**
* OPTIONAL: Strict ETP, more referer trimming, DRM, and more
*/
function applyAdvancedPrivacy()
{
// enforce Strict ETP
user_pref("browser.contentblocking.category", "strict");
// uncomment to allow embedded social posts on webpages
//user_pref("urlclassifier.trackingSkipURLs", "*.reddit.com, *.twitter.com, *.twimg.com, *.tiktok.com");
//user_pref("urlclassifier.features.socialtracking.skipURLs", "*.instagram.com, *.twitter.com, *.twimg.com");
// disable remembering logins, addresses, and payment information
user_pref("signon.rememberSignons", false);
user_pref("extensions.formautofill.addresses.enabled", false);
user_pref("extensions.formautofill.creditCards.enabled", false);
// disable Firefox Sync
user_pref("identity.fxaccounts.enabled", false);
user_pref("browser.firefox-view.feature-tour", "{\"screen\":\"\",\"complete\":true}");
// uncomment to enable search suggestions in the URL bar
// if you use DuckDuckGo, Brave Search, Kagi, etc.
//user_pref("browser.search.suggest.enabled", true);
// control how much referrer information to send across origins
// 1=scheme+host+port+path (BF default), 2=scheme+host+port
user_pref("network.http.referer.XOriginTrimmingPolicy", 2);
// uncomment to disable geolocation services
//user_pref("geo.provider.ms-windows-location", false); // [WINDOWS]
//user_pref("geo.provider.use_corelocation", false); // [MAC]
//user_pref("geo.provider.use_geoclue", false); // [LINUX]
// Sanitize on Close
// uncomment to delete browsing data on shutdown
//user_pref("privacy.sanitize.sanitizeOnShutdown", true);
user_pref("privacy.clearOnShutdown_v2.cache", true); // DEFAULT
user_pref("privacy.clearOnShutdown_v2.cookiesAndStorage", true); // DEFAULT
// change to true to clear browsing history on shutdown
user_pref("privacy.clearOnShutdown_v2.historyFormDataAndDownloads", false);
// DRM
// uncomment both prefs to disable DRM
//user_pref("media.eme.enabled", false);
//user_pref("browser.eme.ui.enabled", false);
// DoH
// uncomment to enforce DNS-over-HTTPS (DoH)
//user_pref("network.trr.mode", 2); // use 3 for max protection
// edit the address to use your own, if desired
//user_pref("network.trr.uri", "https://dns.dnswarden.com/00000000000000000000048"); // Hagezi Light + TIF
user_pref("network.trr.confirmationNS", "skip"); // skip TRR confirmation request
//user_pref("browser.bookmarks.max_backups", 0); // must manually back-up
// auto-decline cookie banners
//user_pref("cookiebanners.service.mode", 1);
//user_pref("cookiebanners.service.mode.privateBrowsing", 1);
// global privacy control (GPC)
//user_pref("privacy.globalprivacycontrol.enabled", true);
}
// -------------------------------------------------------------------------------
/**
* OPTIONAL: Enable features like...
*/
function applyAdvancedSecurity()
{
// PREF: HTTPS-only mode
user_pref("dom.security.https_only_mode", true);
user_pref("dom.security.https_only_mode_error_page_user_suggestions", true);
//user_pref("dom.security.https_only_mode_send_http_background_request", false); // 90s timeout
// change to 1 to allow MiTM (such as your antivirus)
user_pref("security.cert_pinning.enforcement_level", 2);
// PREF: enable hybrid post-quantum key exchange
user_pref("security.tls.enable_kyber", true);
user_pref("network.http.http3.enable_kyber", true);
// PREF: remove special permissions for certain mozilla domains
user_pref("permissions.manager.defaultsUrl", "");
//user_pref("extensions.webextensions.restrictedDomains", "");
}
// -------------------------------------------------------------------------------
function applyAdvancedPerformance()
{
//user_pref("gfx.canvas.accelerated", true); // DEFAULT NON-WINDOWS; enable if using a dedicated GPU
user_pref("gfx.canvas.accelerated.cache-items", 4096);
user_pref("gfx.canvas.accelerated.cache-size", 512);
user_pref("gfx.content.skia-font-cache-size", 20);
user_pref("image.mem.decode_bytes_at_a_time", 32768);
user_pref("network.ssl_tokens_cache_capacity", 10240);
user_pref("network.buffer.cache.count", 128);
user_pref("dom.enable_web_task_scheduling", true);
user_pref("layout.css.grid-template-masonry-value.enabled", true);
// disable Accessibility features
user_pref("accessibility.force_disabled", 1);
// set DNS expiration time
//user_pref("network.dnsCacheExpiration", 3600); // 1 hour; enable if not using DoH
}
// -------------------------------------------------------------------------------
/**
* OPTIONAL: Improve scrolling [Windows and sometimes Linux]
*/
function applyBetterScrolling()
{
// adjust this number to between 10-40
user_pref("mousewheel.min_line_scroll_amount", 10); // default=5
user_pref("apz.overscroll.enabled", true); // DEFAULT NON-LINUX
user_pref("general.smoothScroll", true); // DEFAULT
user_pref("general.smoothScroll.mouseWheel.durationMinMS", 80); // default=50
user_pref("general.smoothScroll.currentVelocityWeighting", "0.15"); // default=.25
user_pref("general.smoothScroll.stopDecelerationWeighting", "0.6"); // default=.4
user_pref("general.smoothScroll.msdPhysics.enabled", false); // [FF122+ Nightly]
}
// -------------------------------------------------------------------------------
/**
* OPTIONAL: Add your custom override prefs to this section
*/
function applyOverrides()
{
//user_pref("browser.tabs.hoverPreview.enabled”, false); // disable tab previews
//user_pref("browser.toolbars.bookmarks.visibility", "never"); // always hide bookmark bar
//user_pref("browser.zoom.full", false); // text-only zoom, not all elements on page
//user_pref("ui.key.menuAccessKey", 0); // remove underlined characters from various settings
//user_pref("general.autoScroll", false); // disable unintentional behavior for middle click
//user_pref("ui.SpellCheckerUnderlineStyle", 1); // dots for spell check errors
//user_pref("reader.parse-on-load.enabled", false); // disable reader mode
//user_pref("devtools.accessibility.enabled", false); // removes un-needed "Inspect Accessibility Properties" on right-click
}
// -------------------------------------------------------------------------------
// run the script
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment