yokoffing / Betterfox

Firefox user.js for speed, privacy, and security. Your favorite browser, but better.
MIT License
4.11k stars 118 forks source link

Updater #167

Open Patrxgt opened 1 year ago

Patrxgt commented 1 year ago

It would be nice to have an updater instead of having to check out. if new version of Betterfox came out. You could fork ArkenFox's updater and edit it to check and pull new versions of user.js from this repo. It also would be a great opportunity to introduce user-overrides.js, so update wouldn't wipe all the user's edits.

ghost commented 1 year ago

Here's a simple batch script I wrote for updating the user.js file

@echo off
powershell invoke-webrequest -uri 'https://github.com/yokoffing/Betterfox/raw/master/user.js' -outfile user.js
pause

I couldn't test so please let me know if it works

unrealapex commented 1 year ago

Here's a oneliner curl script if you are on Linux. It just overwrites user.js with the latest version of the script from the GitHub repository:

curl https://raw.githubusercontent.com/yokoffing/Betterfox/master/user.js > "$(find ~/.mozilla/firefox/ -type d -name "*.default-release")"
ghost commented 1 year ago

Here's a simple batch script I wrote for updating the user.js file

@echo off
powershell invoke-webrequest -uri 'https://github.com/yokoffing/Betterfox/raw/master/user.js' -outfile user.js
pause

I couldn't test so please let me know if it works

The script written in PowerShell


invoke-webrequest -uri "https://github.com/yokoffing/Betterfox/raw/master/user.js" -outfile user.js
pause
unrealapex commented 1 year ago

Just an FYI, this does not update the script file, it just retrieves a new version. It would be better if the new file could be moved to the profiles directory automatically. It is C:\Users\<username>\Appdata\Roaming\Firefox\<profile-name>. In my Bash script, I found the profile directory with a wildcard and moved the file there.

Patrxgt commented 1 year ago

Problem with this method is, that it will remove all of my overrides. It could be nice, if your user.js could support user-overrides.js, like in ArkenFox's user.js

unrealapex commented 1 year ago

Good consideration. Using that idea, you could create an overrides file and append it to the user.js:

#!/bin/bash
# NOTE: this installs to the default profile directory
# update user.js
curl https://raw.githubusercontent.com/yokoffing/Betterfox/master/user.js > "$(find ~/.mozilla/firefox/ -type d -name "*.default-release")"
# append overrides to file
cat user-overrides.js >> "$(find ~/.mozilla/firefox/ -type d -name "*.default-release")"/user.js
Patrxgt commented 1 year ago

Great script! But I still think, that yokoffing should make an official solution to updating and overriding settings in separate file. It would make it way more user friendly and as far as I understand, this user.js is all about delivering privacy in the easiest to use package possible.

yokoffing commented 1 year ago

I've had the honor of meeting a handful of Betterfox users in real life. Do you know how many of them would know how to run a script to update their user.js?

Zero.

I'm aware that we have more advanced users of Betterfox, so an updater would be nice -- but it's also out of scope for the primary audience.

If someone creates a solution, I will happily integrate it and give them credit.

unrealapex commented 1 year ago

Having a shell script seems to be the best approach. As for the normies who don't know how to run a shell script, having a section in the Wiki would help.

Perhaps we should consolidate Arkenfox's user.js update script for a basis for ours? Some ways we could go about overrides in the user.js are either:

  1. Having a separate file with overrides and appending that to the user.js file(proposed by me above)
  2. Extracting user overrides from the old file and insert them into the new file(might be harder to extract)

What do you think is the better approach, or do you have something else in mind?

HyperCriSiS commented 1 year ago

Having a shell script seems to be the best approach. As for the normies who don't know how to run a shell script, having a section in the Wiki would help.

Perhaps we should consolidate Arkenfox's user.js update script for a basis for ours? Some ways we could go about overrides in the user.js are either:

1. Having a separate file with overrides and appending that to the user.js file(proposed by me above)

2. Extracting user overrides from the old file and insert them into the new file(might be harder to extract)

What do you think is the better approach, or do you have something else in mind?

Just came here to ask the same. I think this would be the best solution with also the least of work? I was using the Arkenfox user.js and had many issues. Glad I found this one here. Would be awesome to also have the updater :grinning:

Patrxgt commented 1 year ago

I've had the honor of meeting a handful of Betterfox users in real life. Do you know how many of them would know how to run a script to update their user.js?

Zero.

Emm, no? Double click script is easier than modifying user.js, to copy user's overrides.

Finoderi commented 12 months ago

There is no need to over-engineer an update process. Replacing the user.js and copying/pasting overrides is easy and simple enough already.

Patrxgt commented 11 months ago
  1. It's not over-engineering.
  2. If it's impossible to make an updater, then it would be nice to at least have separate file for user overrides.
Finoderi commented 11 months ago

If you need an updater and a separate file for overrides so badly you can just use arkenfox's 'parrot' nonsense. The less moving parts the project has - the more stable and dependable it is.

VenimK commented 10 months ago

is there a 'updater' for osx

alana-glitch commented 9 months ago

Good news! I've over-engineered the update process 😅

Free-as-in-mattress for anyone who wants to organize overrides per-section, and is comfortable with make: https://codeberg.org/oneirophage/firefox-user-js

yokoffing commented 8 months ago

@alana-glitch Thank you for your work.

stefnotch commented 8 months ago

For future people who want to tackle this: How does one best go about this task? Which tech stack? Which things to watch out for?

Tech stack:

Steps:

  1. Find Firefox user profile. Is this easy, or is this surprisingly finicky? What if the user installed Firefox on a different disk? (One approach seems to be parsing the file at %APPDATA%\Mozilla\Firefox\profiles.ini or ~/.mozilla/firefox/profiles.ini or ~/snap/firefox/common/.mozilla/firefox or *~/Library/Application Support/Firefox/profiles.ini or ...)
  2. Figure out the version of Firefox
  3. Read the current user.js, this could be used to detect if the user did any changes to the user.js file?
  4. Download the new user.js
  5. Make a backup of the Firefox profile
  6. Write the new user.js to the file

What did I miss?

unrealapex commented 8 months ago

Maintaining a shell script for Windows and *Nix wouldn't be too hard. Powershell is a cross platform consideration. Python works too. Judging based off of what yokoffing said previously, it is likely that (Windows) users would need to install the interpreter for the language we choose.

Find Firefox user profile. Is this easy, or is this surprisingly finicky? What if the user installed Firefox on a different disk? (One approach seems to be parsing the file at %APPDATA%\Mozilla\Firefox\profiles.ini or ~/.mozilla/firefox/profiles.ini or ~/snap/firefox/common/.mozilla/firefox or *~/Library/Application Support/Firefox/profiles.ini or ...)

I think a majority of people install Firefox on the same disk as their operating system is on. Perhaps we should make a poll to see if this is something we should consider.

Figure out the version of Firefox

What purpose would detecting browser version be for?

Read the current user.js, and figure out which user.js this corresponds to? (There are multiple versions of Betterfox)

There aren't multiple versions of Betterfox, the other user.js files only contain specific sections of the main user.js.

Download the new user.js Write the new user.js to the file

Having used Betterfox for a few months now, I'd like to share my updated (Bash) script that accomplishes this:

#!/bin/bash

# fetch betterfox user.js
curl -o user.js https://raw.githubusercontent.com/yokoffing/Betterfox/main/user.js

# append user added settings to user.js
echo '

// your settings/overrides here

' >> user.js

# ensure profiles directory is created
if [ ! -d "~/.mozilla/" ]; then
    sleep 5 && killall firefox &
    firefox -headless &
    wait
fi
# move user.js into firefox default profile directory
mv user.js "$(find ~/.mozilla/firefox/ -type d -name "*.default-release")"
stefnotch commented 7 months ago

If we do end up choosing something that requires an extra installation, then it'd be lovely if that were as simple as possible for the end-user.

Python is an excellent example, since installing Python in Windows using the official installer frequently fails. And uninstalling it is equally error-prone. Meanwhile, if the script starts off by

  1. Check if Python is installed
  2. If not, download a binary from PyPy and use that then the user experience would be near-perfect. The user wouldn't even have to know that the script relies on Python.

I think a majority of people install Firefox on the same disk as their operating system is on. Perhaps we should make a poll to see if this is something we should consider.

There can be multiple Firefox profiles, so that's maybe also worth keeping in mind.

What purpose would detecting browser version be for?

Every Firefox version has a corresponding version of Betterfox. It'd be weird if the updater could update the Betterfox script before Firefox got around to doing its update.

And the second consideration would be that there are multiple Firefox release channels, like Firefox Nightly, Firefox Beta, Firefox ESR.

There aren't multiple versions of Betterfox, the other user.js files only contain specific sections of the main user.js.

Ah, I see. Thank you for clearing that up.

Having used Betterfox for a few months now, I'd like to share my updated (Bash) script that accomplishes this:

On that note, apparently arkenfox's user.js also has a shell script https://github.com/arkenfox/user.js/blob/master/updater.sh

And finally, I noticed that I missed an important step: Making a backup of the Firefox profile. The wiki seems to strongly recommend it, so I suppose it'd be useful to have that in an installer script as well. (Of course as a skip-able option.)

unrealapex commented 7 months ago

What are your thoughts on an executable? The concept of running an executable would be familiar for Windows users and we could bundle any dependencies for the tooling we use with it.

There can be multiple Firefox profiles, so that's maybe also worth keeping in mind. Good consideration. Every Firefox version has a corresponding version of Betterfox. It'd be weird if the updater could update the Betterfox script before Firefox got around to doing its update.

I forgot about the releases, thank you for pointing that out! We could probably get the version number from the Firefox binary and form a URL with the version number.

And finally, I noticed that I missed an important step: Making a backup of the Firefox profile. The wiki seems to strongly recommend it, so I suppose it'd be useful to have that in an installer script as well. (Of course as a skip-able option.)

Ah that is something I overlooked too.

stefnotch commented 7 months ago

A simple executable would be awesome for Windows users.

In my case, it'd make it very nice and easy to convince my friends to use Betterfox. "Oh you're using Firefox? Here, try downloading and running Betterfox, it simply makes your experience slightly better."