"An era can be said to end when its basic illusions are exhausted." - Arthur Miller

Thursday, March 08, 2018

Firefox: "Do This Automatically for Files Like This" Is Greyed Out

Recently Firefox changed how the browser works at a fundamental level in what they called Firefox Quantum or Firefox v57 and up. Despite the update one of the long term problems (to me anyway) is the issue of the open dialog box where "Do this automatically for files like this from now on." is greyed out. As a result you do not get to tell Firefox how to handles these file types (or extension and what Mozilla calls a MimeType) from now on so do not have to keep verifying if it should download automatically or open a certain program. There is a technical reason for why its greyed out but it really doesn't matter because its a server side setting that you as the user has no control over and so you can't force that option to not be greyed out. The problem is the powers that be at Mozilla have long decided that the user should not be able to manually add extensions types via the gui interface.

Fortunately there is a fix that I found by combined multiple poor answers from various forums. Why people skip all the steps when explaining how to fix something always confuses me since they are trying to be helpful but provide answers that assumes their audience mostly knows the answer and just needs a nudge in a particular direction. In the pre-quantum days, the fix involved editing the mimeTypes.rdf file. Now it involves editing a different file called handlers.json. Now these instructions are going to assume you know the basics of your computer as some parts will change based on which version of Windows you have. If not sure how to do something like open Windows Explorer or Run, google it for your operating system.

To start, see how things are setup currently so you can tell if your changes worked.

- Go to the Hamburger Icon (three dashes stacked in a column) > then click Options.

- In the Options tab that opens, go to the search box and type "Applications" as see in screenshot (alternatively click "General" then scroll down to "Application" section).

- Take a mental snapshot or a literal one so can tell if your changes are working.

Add file extensions to this list:

- Via Windows Explorer or Run, go to: %AppData%\Mozilla\Firefox\Profiles > then double-click your Firefox profile folder (usually only one there or one with most recent change date).

- Scroll past the folders to the individual files and look for: handlers.json > copy this file and save it on your desktop. This is just a back-up in case have to reset your changes.

- Now in the Profiles folder right-click over handlers.json > click Edit

- A text file will open that looks something like this assuming Word Wrap is checked:
{"defaultHandlersVersion":{"en-US":4},"mimeTypes":{},"schemes":{"ircs":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"mailto":{"action":4,"handlers":[null,{"name":"Yahoo! Mail","uriTemplate":"https://compose.mail.yahoo.com/?To=%s"},{"name":"Gmail","uriTemplate":"https://mail.google.com/mail/?extsrc=mailto&url=%s"}]},"irc":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"webcal":{"action":4,"ask":true,"handlers":[null,{"name":"30 Boxes","uriTemplate":"https://30boxes.com/external/widget?refer=ff&url=%s"}]}}}

- For each file type you want to add to the list, the goal is to insert this text in the correct location based on file format where FileType=""> is what you want to add:
,"application/FileType":{"action":0,"extensions":["FileType"]}

- Create your own list like example below keeping the beginning , and the ending }
Examples:
,"application/mp3":{"action":0,"extensions":["mp3"]}
,"application/rar":{"action":0,"extensions":["rar"]}
,"application/zip":{"action":0,"extensions":["zip"]}

- Combine that list, without spaces anywhere
Example:
,"application/mp3":{"action":0,"extensions":["mp3"]},"application/rar":{"action":0,"extensions":["rar"]},"application/zip":{"action":0,"extensions":["zip"]}

- Now delete the very first comma only
Example:
"application/mp3":{"action":0,"extensions":["mp3"]},"application/rar":{"action":0,"extensions":["rar"]},"application/zip":{"action":0,"extensions":["zip"]}

- Copy and paste your combined code

- Go back to the open handlers.json file. Look for this section of code at the very beginning:
{"defaultHandlersVersion":{"en-US":4},"mimeTypes":{}

- See those two brackets after "mimeTypes"? That is where you will paste your code.
Example:
{"defaultHandlersVersion":{"en-US":4},"mimeTypes":{"application/mp3":{"action":0,"extensions":["mp3"]},"application/rar":{"action":0,"extensions":["rar"]},"application/zip":{"action":0,"extensions":["zip"]}},"schemes":{"ircs":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"mailto":{"action":4,"handlers":[null,{"name":"Yahoo! Mail","uriTemplate":"https://compose.mail.yahoo.com/?To=%s"},{"name":"Gmail","uriTemplate":"https://mail.google.com/mail/?extsrc=mailto&url=%s"}]},"irc":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"webcal":{"action":4,"ask":true,"handlers":[null,{"name":"30 Boxes","uriTemplate":"https://30boxes.com/external/widget?refer=ff&url=%s"}]}}}

- Save the text file (not "Save As", just "Save")

- Close Firefox.

- Re-open Firefox.

- Go to the Hamburger Icon > Options > type "Applications" in search box > see if your items are in the list (see screenshot)

- With my config, the default behavior is "Save File" but click the drop down for each and make changes as you see fit.

If you wish to add more formats later, go to the code and look for },"schemes":. You will make the changes right before the }.
For example, lets add an mkv file type. So from above the code is this: ,"application/mkv":{"action":0,"extensions":["mkv"]}

- To add:
Example:
{"defaultHandlersVersion":{"en-US":4},"mimeTypes":{"application/mp3":{"action":0,"extensions":["mp3"]},"application/rar":{"action":0,"extensions":["rar"]},"application/zip":{"action":0,"extensions":["zip"]}},"schemes":{"ircs":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"mailto":{"action":4,"handlers":[null,{"name":"Yahoo! Mail","uriTemplate":"https://compose.mail.yahoo.com/?To=%s"},{"name":"Gmail","uriTemplate":"https://mail.google.com/mail/?extsrc=mailto&url=%s"}]},"irc":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"webcal":{"action":4,"ask":true,"handlers":[null,{"name":"30 Boxes","uriTemplate":"https://30boxes.com/external/widget?refer=ff&url=%s"}]}}}

- Now becomes
Example:
{"defaultHandlersVersion":{"en-US":4},"mimeTypes":{"application/mp3":{"action":0,"extensions":["mp3"]},"application/rar":{"action":0,"extensions":["rar"]},"application/zip":{"action":0,"extensions":["zip"]},"application/mkv":{"action":0,"extensions":["mkv"]}},"schemes":{"ircs":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"mailto":{"action":4,"handlers":[null,{"name":"Yahoo! Mail","uriTemplate":"https://compose.mail.yahoo.com/?To=%s"},{"name":"Gmail","uriTemplate":"https://mail.google.com/mail/?extsrc=mailto&url=%s"}]},"irc":{"action":2,"ask":true,"handlers":[null,{"name":"Mibbit","uriTemplate":"https://www.mibbit.com/?url=%s"}]},"webcal":{"action":4,"ask":true,"handlers":[null,{"name":"30 Boxes","uriTemplate":"https://30boxes.com/external/widget?refer=ff&url=%s"}]}}}

- Remember to close and re-open Firefox to apply the change.

If you mess up, don't forget you have the original file on your desktop. Just copy it and paste it back to the profiles folder, confirming you want to replace the previous file. Just like that you reset your changes. Alternatively you can close Firefox, delete handlers.json, and when you open Firefox again it will recreate the file as when program was first installed.



18 comments:

  1. Thank you ! Worked for jpg :)

    ReplyDelete
  2. Very well done! Super explanation and you were right, others just skim over the subject without detailed info like yours. Thanks a bunch.

    ReplyDelete
  3. Works like a charm, thanks

    ReplyDelete
  4. This is no longer valid. Completely different formatting in that file.

    ReplyDelete
  5. Thanks, this was on point and very helpfull...

    ReplyDelete
  6. This really helped me, thank you so much! :)

    ReplyDelete
  7. I don't have an edit option when I right click on the handlers.json file.

    ReplyDelete
  8. Thank you so much for this! I was getting mad with .fit extensions - I couldn't change the default behavior within firefox - after modifying the .json file I am :-)
    Thank god (or google) I found your article!

    ReplyDelete
  9. nice it fixed my bittorrent, thanx

    ReplyDelete
  10. Thanks for this great tutorial! I'm running the MacOS version of Firefox and it works just as you describe.

    Open the Finder. From the Go menu, select "Go to Folder" (Keyboard Shortcut: Shift+Command+G) Type: ~/Library/Application Support/Firefox/Profiles

    ReplyDelete
  11. Very nice! Worked like charm! Thanks a lot.

    ReplyDelete
  12. Thank you very much for this, it was driving me nuts.

    ReplyDelete
  13. thank-you; there are 6.3M hits on Google for this problem, going back 14 years, yours' is the only one that works

    ReplyDelete
  14. please note that "action":0 saves file automatically but change to "action":2 opens the file (helpful for torrent files)

    ReplyDelete
  15. Thanks so much!

    That really explained how to edit the hander.json file very well to add file extention types. I was getting nowhere looking at google or reading other peoples methods and was getting irratated in having to click SAVE as the Do this... box was greyed out.

    ReplyDelete
  16. Brilliant, thank you. This worked perfectly in Waterfox 2020.04

    ReplyDelete
  17. Believe it or not, this nearly 3 year old blog just helped me tonight. I finally upgraded to the latest version of FF (stuck with 56 for the longest time!) and really didn't like I couldn't set it to always save .rar files. Thanks for this!!!

    ReplyDelete
  18. Works Like charm ! Thank you

    ReplyDelete