I held out as long as I could, but when every other site tells you your browser is outdated, it's time to give up and move on. So I switched, very recently, from Firefox 3.6 to 9. And well, you know what happened next :-)
Sure, I expected problems with extensions, but not to the point where just lying to Firefox about the extension's version compatibility would no longer work. It no longer works. Something changed dramatically in how Firefox handles menus and toolbars, so each and every extension that added a menu item or a toolbar button is now dead. Completely.
Now, this isn't going to help everyone, but perhaps some DC readers will find it useful. I can give up on a lot, but there are several extensions and modifications that I absolutely cannot live without. They are:
- "Paste and go" in the address bar and "Paste and search" in the search bar.
- A Save button on the toolbar for File -> Save Page As command.
- A context menu command to copy current page title, selection (if any) and address to clipboard.
- A modification of how Firefox saves pages to disk: (a) use page title instead of the document filename, which is usually "index.php" or something equally useless, and (b) use the selected text, if any, as filename.
For all that I had relied on a bunch of extensions and self-made modifications that I had always been able to carry over from one FF release to another. Until now. With FF 9, I've had to re-do them all from scratch or find alternative solutions. Here's how I did that, FWIW.
(a) "Paste and go" in the address bar and "Paste and search" in the search bar.This one was easy. The "Paste and go" extension is no longer supported, but its functionality has finally been added to the Firefox core. No doubt it was because Google Chrome had thought of it earlier; the FF developers had never figured out by themselves that the #1 reason to paste anything in the address bar... better late than never! IE still doesn't get that.
(b) A Save button on the toolbar for File -> Save Page As command.This one required some work, but was easy.
The old way no longer seems to work. Happily, there is a new extension that's even better:
Custom Buttons. This one lets you create buttons inside the browser, and it is not limited to a predefined set of functions. Instead, you can assign any JavaScript code to a button you create - from a single FF function to a script of any complexity. You can pick your own button image as well, of course, and set a few other options. I'm not all that conversant with Firefox's internals, but the extension home has a detailed FAQs and a user forum if you need help. So after some looking stuff up and tweaking the code, I ended up with a button definition that looks like this:
...and a Save button on the bookmarks toolbar:
Done!
(c) A context menu command to copy current page title, selection (if any) and address to clipboard.This one took some more work. Previously, I had used an extension called CopyUrlPlus. It would add a submenu to FF context menu, with commands like "Copy Title and URL", "Copy Title, Selection and URL", etc. Exactly what I needed. There were not many options, but you could tweak the extension's JavaScript code to add your own related commands or modify their behavior. This one is of huge importance to me, because I run my old, creaky bookmark manager set to capture URLs with titles from clipboard, and I use it to archive almost everything I ever read or want to read later. Well, the extension no longer works at all, as the mechanism for adding commands to the context menu in FF has changed. I suppose I could learn that part and update the extension, but instead I went looking for a newer equivalent.
I found it in
QuoteURLText. It does almost the same as CopyUrlPlus used to do, but "almost" makes a big difference in this case. It would only copy current selection and page URL; and if there were no selection, it would do nothing at all. Plus, it would add "field" names before each line, such as "Address: " or "Source:". I don't want that, because it breaks the URL and title recognition in my app. So, JavaScript time again!
I did a horrible hack with that. It was already late and I wanted to get the results I needed as quickly
as I could. I ripped out some prefs I do not need, such as copying with HTML formatting, and changed the code around to suit my purpose. Instead of two or three separate commands I now have only one. If some text is selected, the extension copies the selection and the URL. If no selection is present, it copies page title and the URL. It does not copy all three, but with some more tweaking it is certainly possible.
I won't post my code here, because I'm not even sure if QuoteText license would permit that, but if anyone wants my modifications, just PM me.
(d) A modification of how Firefox saves pages to disk: (a) use page title instead of the document filename, and (b) use the selected text, if any, as filename.I really cannot understand why FF does not do it already. It actually contains code that does at least (a), but for some reason that code is never used. As a result, FF saves pages with unhelpful filenames.
Alas, no extension ever did that part, and I don't think it even could. To get what I want, I've always had to hack Firefox's internal JavaScript. Under FF installation folder there used to be a file called toolkit.jar. A .jar file is just a .zip file with a different extension, so it can be easily browsed. Inside it, there's a piece of JavaScript called "contentAreaUtils.js", and
in it there is a function named "getDefaultFileName()", which does what it says: generates a filename Firefox uses when you click File -> Save Page As. I have a snippet of JavaScript code that I would simply put on top of that function, copy the .js file back into toolkit.jar and that did the trick.
So I had a near breakdown when I saw the latest FF does not even come with a "toolkit.jar" :-) After some digging, it turns out that several .jar files have been merged into one, now called appropriately "omni.jar". And sure enough, contentAreaUtils.js is inside it, under "chrome\toolkit\content\global". It still contains the getDefaultFileName() function, but its parameters have changed and its code is now different, but never mind. The old trick still works. Put the following on top of that function, and Firefox will instantly become much smarter when saving files:
if (aDocument) {
// use selection, if any
var mjSelText = aDocument.getSelection();
mjSelText = mjSelText.replace(/(\n|\r)+/g, " ");
mjSelText = validateFileName(mjSelText).replace(/^\s+|\s+$/g, "");
mjSelText = mjSelText.replace(/ +/g, " " );
if (mjSelText != "") {
return mjSelText;
}
var docTitle = validateFileName(aDocument.title).replace(/^\s+|\s+$/g, "");
if (docTitle != "") {
// Use the document title
return docTitle;
}
}
First, it checks whether any text is selected, and if so, it replaces any illegal characters with spaces and returns the result. Second, if no selection, it does the same with the page title. If neither works, it gives up and Firefox takes over with its own code. Later on Firefox actually checks for docTitle and uses it, but for some reason the function always returns earlier, so that code never runs. I just put it on top of the function instead, preceded only by the check for selection.
Of course Windows will complain badly when you try to replace "omni.jar" under Program Files with your own, but eventually you'll get your way.
And it's all good now.