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

Updater #167

Open
Patrxgt opened this issue Apr 28, 2023 · 22 comments
Open

Updater #167

Patrxgt opened this issue Apr 28, 2023 · 22 comments
Assignees

Comments

@Patrxgt
Copy link

Patrxgt commented Apr 28, 2023

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
Copy link

ghost commented Apr 29, 2023

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
Copy link

unrealapex commented May 3, 2023

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
Copy link

ghost commented May 6, 2023

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
Copy link

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
Copy link
Author

Patrxgt commented May 9, 2023

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
Copy link

unrealapex commented May 9, 2023

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
Copy link
Author

Patrxgt commented May 9, 2023

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 yokoffing added ⬆️ enhancement New feature or request help wanted Extra attention is needed labels May 9, 2023
@yokoffing
Copy link
Owner

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
Copy link

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
Copy link

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 😀

@Patrxgt
Copy link
Author

Patrxgt commented Jul 7, 2023

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
Copy link

Finoderi commented Jul 12, 2023

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
Copy link
Author

Patrxgt commented Jul 14, 2023

  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
Copy link

Finoderi commented Jul 14, 2023

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.

@yokoffing yokoffing removed the ⬆️ enhancement New feature or request label Jul 24, 2023
Repository owner deleted a comment from mehdifirefox Aug 1, 2023
@yokoffing yokoffing removed the help wanted Extra attention is needed label Aug 20, 2023
@VenimK
Copy link

VenimK commented Aug 31, 2023

is there a 'updater' for osx

@alana-glitch
Copy link

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
Copy link
Owner

@alana-glitch Thank you for your work.

@stefnotch
Copy link

stefnotch commented Nov 10, 2023

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:

  • Should be cross platform
  • Should be as simple as possible, both for devs and for the end user
    e.g. If we go with shell scripts, then we would need to maintain one script for Windows, and one for Linux.

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
Copy link

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
Copy link

stefnotch commented Nov 11, 2023

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
Copy link

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
Copy link

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."

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

No branches or pull requests

9 participants