I want to share with the habocoobschestvomu two recipes for "cooking" Firefox for a more pleasant and convenient use in the daily life of Unix.
We will talk about the version of Firefox for FreeBSD. But everything described below is quite applicable to the version for Linux. For Windows, everything is not so simple and is solved in other ways.
I will describe the Emacs-style keyboard shortcuts for Firefox, as well as how to get Firefox to download any content on the clipboard via mouse middleclick, not just the one that looks like a link (it has
http: // prefix, etc.) .
')
If the topic is interesting, please under the cat.
So. Each of us who, for various reasons, uses the shell (in particular, bash) is probably familiar with Emacs-style keybindings. For example:
Ctrl - a: go to the beginning of the line
Ctrl - e: go to end of line
Ctrl - u: delete to the beginning of the line
Ctrl-k: delete to end of line
Etc.
I am so used to using these keyboard shortcuts that I often try to use them by inertia in other programs. In particular, in Firefox. However, this leads to unexpected results. For example, the combination “Ctrl - w”, instead of deleting a word in front of the cursor, simply closes the current tab.
Once upon a time I was tired of this state of affairs and I used the method found in the vast
MozillaZine . And since then I have been using this solution with every update of Firefox. Below I will describe the sequence of actions.
First we need an installed Firefox. On FreeBSD, it can be installed from the ports collection (
ports / www / firefox ). Next, you need to take the file
toolkit.jar . By default, it is installed in the
/ usr / local / lib / firefox / chrome / directory on FreeBSD. Then it needs to be unpacked. This can be done using the
jar utility from the JDK
distribution , or the
fastjar utility (
ports / archivers / fastjar ), or
using the usual
unzip :
mkdir /tmp/firefox/ && cd /tmp/firefox/ && cp /usr/local/lib/firefox/chrome/toolkit.jar /tmp/firefox/ && fastjar -xf toolkit.jar
The contents of the archive will be unpacked in the current directory. Next, add the following to the
content / global / platformHTMLBindings.xml file:
1) in the <handlers> section of the <binding id = "inputFields"> section <handler event="keypress" key="a" modifiers="control" command="cmd_beginLine"/> <handler event="keypress" key="e" modifiers="control" command="cmd_endLine"/> <handler event="keypress" key="b" modifiers="control" command="cmd_charPrevious"/> <handler event="keypress" key="f" modifiers="control" command="cmd_charNext"/> <handler event="keypress" key="h" modifiers="control" command="cmd_deleteCharBackward"/> <handler event="keypress" key="d" modifiers="control" command="cmd_deleteCharForward"/> <handler event="keypress" key="w" modifiers="control" command="cmd_deleteWordBackward"/> <handler event="keypress" key="u" modifiers="control" command="cmd_deleteToBeginningOfLine"/> <handler event="keypress" key="k" modifiers="control" command="cmd_deleteToEndOfLine"/>
2) in the <handlers> section of the <binding id = "textAreas"> and <binding id = "editor"> sections <handler event="keypress" key="a" modifiers="control" command="cmd_beginLine"/> <handler event="keypress" key="e" modifiers="control" command="cmd_endLine"/> <handler event="keypress" id="key_left" key="b" modifiers="control" command="cmd_charPrevious"/> <handler event="keypress" id="key_right" key="f" modifiers="control" command="cmd_charNext"/> <handler event="keypress" id="key_delback" key="h" modifiers="control" command="cmd_deleteCharBackward"/> <handler event="keypress" id="key_delforw" key="d" modifiers="control" command="cmd_deleteCharForward"/> <handler event="keypress" id="key_delwback" key="w" modifiers="control" command="cmd_deleteWordBackward"/> <handler event="keypress" id="key_del_bol" key="u" modifiers="control" command="cmd_deleteToBeginningOfLine"/> <handler event="keypress" id="key_del_eol" key="k" modifiers="control" command="cmd_deleteToEndOfLine"/> <handler event="keypress" id="key_linedown" key="n" modifiers="control" command="cmd_lineNext"/> <handler event="keypress" id="key_lineup" key="p" modifiers="control" command="cmd_linePrevious"/>
After this, we archive the archive back: "
fastjar -cf toolkit.jar */
" (or with the help of "
zip -r
"). And move it to the source directory:
mv toolkit.jar /usr/local/lib/firefox/chrome/toolkit.jar
To do this, you need root rights. Also, of course, the
toolkit.jar file
must first be
saved .
Restart Firefox and enjoy the Emacs style keyboard shortcuts in all text fields, including the browser’s address bar.
So that every time when the new version of Firefox comes out, do not dig into the content of the
content / global / platformHTMLBindings.xml file, I wrapped these changes in a
patch .
Go ahead. Starting from the 4th version of Firefox, I was faced with the fact that by pressing the middle mouse button the browser no longer tries to download the link from the clipboard if this link does not have a corresponding prefix (
http: // , etc.). Ie, if I copy the name of a virtual host from a web server log, to look at its web site in a browser, then instead of the usual middle click in the browser window, I have to put the cursor in the address bar, insert content there Clipboard and press Enter. This, to put it mildly, the innovation so dismayed me that it made me turn again to the search for solutions in the vast web. And the
solution was found. It assumes the same procedure as the method described above. Only the files we edit will be different. We take the file
browser.jar from the
/ usr / local / lib / firefox / chrome / directory, back it up and unpack it. Further in the
content / browser / browser.js file we find the following block:
try { makeURI(url); } catch (ex) {
and replace it with this:
var URIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"] .getService(Components.interfaces.nsIURIFixup); url = URIFixup.createFixupURI(url, 1).spec;
Save, pack back and move the newly created
browser.jar back to the
/ usr / local / lib / firefox / chrome / directory. We reload the browser, make sure that in
about: config the contentLoadURL option is
true and enjoy the result: now when the middle mouse button is pressed, the browser will try to download any content from the clipboard, and not just the one that it considers a link.
As with the previous method, you can also use the
corresponding patch .
Both methods have been used by me for a long time and have already been tested for performance in the recently released FF 10.0.
One minus of this approach: patches need to be applied after each update of Firefox.
I hope this article will be useful and will bring someone more satisfaction and pleasure from working in your favorite browser.
The following materials were used in the article:
1.
Emacs Keybindings - Firefox (MozillaZine).
2.
Firefox 4: Fixing middlemouse.content load, and hacking jars (ShallowSky.com).