In Firefox, when using File->Save Page As..., I want currently selected text (if any) to be used as the suggested filename. (Standard behavior is to use document title if available; earlier versions just used the filename from the URL).
What is the proper way of doing this? Can it be done with an extension, for instance? What do I need to read?
Optional explanation: it used to be possible. For years (at least since 2006), after installing a new version of Firefox I would open the file omni.jar (omni.ja these days), locate within it a file called 'contentAreaUtils.js', and add a few lines of code at the top of the 'getDefaultFileName()' function. It worked flawlessly for 10 years. With the recent versions of Firefox though, it no longer does. Long story short, almost any modification to that file causes Firefox to stop reacting to Ctrl+S altogether. If I put
at the top of the function, it works as expected. but if I put
var myABC = 'abc'; return myABC;
then Firefox no longer does anything on Ctrl+S.
console.log doesn't seem to work from inside there, and overall, the behavior seems to be almost random - sometimes just placing a comment at the top of the function seems to break it. Yes, I know (some) js and (some) DOM; my js code is syntactically correct. What I don't know is Firefox internals and how they apparently changed at some point in 2016. Is Firefox testing integrity of this file somehow? What is the proper way of implementing this?