Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some scripts that can be used to customize Firefox for better privacy. #338

Open
plantindesk opened this issue Mar 28, 2024 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@plantindesk
Copy link

plantindesk commented Mar 28, 2024

Operating system

Windows, macOS, or Linux.

Name

Tweaks For Firefox

Code

function Add-PrefsToJsFile {
  param (
    [Parameter(Mandatory = $true)]
    [string] $FilePath,
    [Parameter(Mandatory = $true)]
    [array] $DataToInsert
  )
  try {
    $linesToInsert = @("")
    foreach ($item in $DataToInsert) {
      if ($item.key -and $item.value) {
        $linesToInsert += 'user_pref("' + $item.key + '", ' + $item.value + ');'
      } else {
        Write-Warning "Invalid item in data: $item"
      }
    }
    Add-Content -Path $FilePath -Value $linesToInsert
    Write-Verbose "Successfully added preferences to '$FilePath'."
  } catch {
    Write-Error "Error adding content to '$FilePath': $_"
    Write-Log -LogName Application -Message "Error adding content to '$FilePath': $_" -EventID 1
    [System.Windows.Forms.MessageBox]::Show("An error occurred while adding content to the file.", "Error", "OK", "Error")
  }
}
$dataToInsert = @(
    [PSCustomObject]@{ key = "media.peerconnection.enabled"; value = "false" },
    [PSCustomObject]@{ key = "privacy.resistFingerprinting"; value = "true" },
    [PSCustomObject]@{ key = "privacy.trackingprotection.fingerprinting.enabled"; value = "true" },
    [PSCustomObject]@{ key = "privacy.trackingprotection.cryptomining.enabled"; value = "true" },
    [PSCustomObject]@{ key = "privacy.firstparty.isolate"; value = "true" },
    [PSCustomObject]@{ key = "privacy.trackingprotection.enabled"; value = "true" },
    [PSCustomObject]@{ key = "geo.enabled"; value = "false" },
    [PSCustomObject]@{ key = "media.navigator.enabled"; value = "false" },
    [PSCustomObject]@{ key = "network.cookie.cookieBehavior"; value = 1 },
    [PSCustomObject]@{ key = "network.cookie.lifetimePolicy"; value = 2 },
    [PSCustomObject]@{ key = "network.dns.disablePrefetch"; value = "true" },
    [PSCustomObject]@{ key = "network.prefetch-next"; value = "false" },
    [PSCustomObject]@{ key = "dom.event.clipboardevents.enabled"; value = "false" },
    [PSCustomObject]@{ key = "media.eme.enabled"; value = "false" }
)
Add-PrefsToJsFile -FilePath "<path-to-user-profile>/prefs.js" -DataToInsert $dataToInsert
OS Path
Windows NT (NT4.x/2000/XP/Vista/7/8/10) "%APPDATA%\Mozilla"
Unix/Linux ~/.mozilla/
Mac OS X ~/Library/Mozilla/ ~/Library/Application Support/

Revert code

network.cookie.cookieBehavior

This is an integer type preference with different values. Here are the cookie preference options:

  • 0 = Accept all cookies by default
  • 1 = Only accept from the originating site (block third-party cookies)
  • 2 = Block all cookies by default
  • 3 = Block cookies from unvisited sites
  • 4 = New Cookie Jar policy (prevent storage access to trackers)

Choosing between 1 and 4 would improve privacy. The New Cookie Jar policy (value 4) provides more protection, but may break some sites' functionality.

network.cookie.lifetimePolicy = 2

This is another integer type preference that you should set to a value of 2. This preference determines when cookies are deleted. Here are the different options:

  • 0 = Accept cookies normally
  • 1 = Prompt for each cookie
  • 2 = Accept for current session only
  • 3 = Accept for N days

Setting this to 2 should allow the websites you visit to work and all cookies will be automatically deleted after the session.

Category

Configuring Browsers
|
|_____Firefox

Recommendation level

STRICT

References

Restore Privacy

@plantindesk plantindesk added the enhancement New feature or request label Mar 28, 2024
@undergroundwires
Copy link
Owner

Hi @plantindesk, thank you for the suggestion. If you check Linux > Configure programs > Configure Firefox, you'll see that almost all of these are covered.

We need a way to share scripts between OSes, it would be painful to replicate these in Windows, better to roll to all three platforms including macOS from same place. I need to refactor how scripts are compiled to achieve this so the compiler allow using shared scripts/categories between collections.

I will check other missing ones and can add on Linux and implement share mechanism so Windows collection can use all stuff Linux has. This will take time though.

Some comments:

  • You do not want to enable privacy.firstparty.isolate, disable it but keep network.cookie.cookieBehavior with option 5. You can search for those in Linux collection and read more.
  • I think ´network.cookie.lifetimePolicywith2` is too aggressive, but we can add this without recommending it.

@plantindesk
Copy link
Author

plantindesk commented Mar 29, 2024

Yes, we can indeed disable telemetry in various desktop environments such as KDE, GNOME, and others. To provide an example, in the case of the KDE desktop environment, there is a package called kdeuserfeedback that gathers user data through telemetry and feedback surveys. By disabling this package, we can prevent any further collection of user information.

Furthermore, For Solus OS, we may consider adding a script to remove its telemetry functionality entirely.

@undergroundwires
Copy link
Owner

They're great suggestions but I don't know how to do those. I can add these only if I knew how to disable KUserFeedback or remove telemetry in Solus OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants