Skip to content

Commit 278a3cd

Browse files
authored
Default to last Firefox install if multiple
When _not_ explicitly requesting a specific Firefox profile directory the default profile is chosen. However on top of profiles Firefox may have multiple "installs" (listed in the `installs.ini` file) each with their own default profile. Before, the default profile was the one from the first install. However, it makes more sense to pick the last one instead, assuming that that's the most recently created one, and thus the active one.
1 parent ae731e3 commit 278a3cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pycookiecheat/firefox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def _find_firefox_default_profile(firefox_dir: Path) -> str:
107107
profiles_ini.read(firefox_dir / "profiles.ini")
108108
installs = [s for s in profiles_ini.sections() if s.startswith("Install")]
109109
if installs: # Firefox >= 67
110-
# Heuristic: Take the first install, that's probably the system install
111-
return profiles_ini[installs[0]]["Default"]
110+
# Heuristic: Take the most recently created profile which should be the active one.
111+
return profiles_ini[installs[-1]]["Default"]
112112
else: # Firefox < 67
113113
profiles = [
114114
s for s in profiles_ini.sections() if s.startswith("Profile")

0 commit comments

Comments
 (0)