Multiple sources online will tell you to set privacy.resistFingerprinting to true, but that didn't work for me.
The issue is actually more deep-seated than you might think:
With many thanks to this reddit post, I will restate the core takeaways from it here:
- Firefox possibly stores the last window position in
xulstore.json in the profile directory, but deleting that doesn't help (which I can personally confirm as well).
- Additionally, firefox also stores the last window position in
sessionstore.jsonlz4, which is harder to edit due to being compressed in a non-standard format.
Now for the actual solution that has worked for me so far (I've been repeatedly testing it for a few minutes).
Use the following script to start firefox:
#!/usr/bin/env sh
config_dir="$HOME/.mozilla/firefox" # <-- set this to where your firefox config directory is (it's probably already correct)
profile_name="main" # <-- set this to your profile folder name, which you can find out by going to about:profiles
cd "$config_dir/$profile_name"
for good measure (there shouldn't be anything meaningful in there anyway)
rm xulstore.json
[ -e sessionstore.jsonlz4 ] && {
t=mktemp
&& cat sessionstore.jsonlz4 | jsonlz4tool d | jq 'del(.windows.[].screenX) | del(.windows.[].screenY)' | jsonlz4tool c >"$t"
&& cp "$t" sessionstore.jsonlz4
}
firefox "$@"
You will need to have jq and jsonlz4tool installed.
The latter is a tool I wrote myself that can compress and decompress .jsonlz4 files (see this answer for more details). You can probably also make it work with dejsonlz4, but I haven't tried it.