Here's a little hack I worked up (with lots of assistance and hand-holding from fuzzie - I don't know any JavaScript!) to allow you to pop up an e2 search box by simply drawing an 'e' with your mouse over a Mozilla window.

First things first, install Optimoz gesture control - a Mozilla enhancement that allows you to control basic browser functions using mouse gestures. Optimoz can be found at:
http://optimoz.mozdev.org/

Once you have installed Optimoz, gotten it configured to your liking, and passed through the stage where you're randomly waving your mouse around and giggling as your windows magically appear and disappear, you're ready to apply this small hack.

As of yet, there's no simple way to add or modify Optimoz gestures. However, since it's all based on JavaScript and XUL anyway, all that's involved is pasting some text into two text files.


The first file you need to modify is called gestimp.js. This will be in a different place depending on your OS, and where you decided to install Mozilla.
Assuming you installed Mozilla in the default install location, you'll find the file in these directories:
Linux: /usr/lib/mozilla/chrome/mozgest/content/
Windows: C:\program files\mozilla.org\mozilla\chrome\mozgest\content\
Mac OS: *mozilla-install-dir*/chrome/mozgest/content/ (where *mozilla-install-dir* is wherever you installed Mozilla to)

Open up gestimp.js in a simple text editor (Notepad, for instance) and scroll down until you find // *** misc ***. Now copy the line of code below and paste it in below the 'misc' line.

  addGesture("RULDR", bundle.getString("g.openE2SearchBox"), "openE2SearchBox();");

Scroll down to the bottom of the file and insert the following:

function openE2SearchBox(){
   void(q=prompt('Enter text to search:',''));
   if(q) window._content.document.location='http://www.everything2.com/?node='+escape(q);
}

We're not finished yet. Go up one directory in the tree (to the /mozgest dir) and look for the locale dir. Inside here should be another dir called en-US, and inside that one a second mozgest dir. Inside this is the second file we need to modify - mozgest.properties. Open this in a text editor, and scroll down until you find a big block of text with # gesture descriptions on top. Copy and paste the line below into the file, below the last entry in the gesture descriptions list.

g.openE2SearchBox=Search for text on E2

Save both files, then close and reopen Mozilla. Under linux you may have to re-register the files to get it to work. (please do not ask me what this means. I don't run Linux. I've only used Mozilla for one day. Go prod fuzzie instead.)


Okay, you're finished the modifications; now here's the fun part. Hold down whatever button you use for gesture control (the default is left mouse button, although I find the right more convenient) and move your mouse Right, Up, Left, Down and Right again, in a sort of square 'e' shape. A little box should pop up for you to type your search text into. Type in some text, hit OK, be happy.

If it doesn't, repeat the gesture, but don't let go of the button at the end. Look at the status bar - it should say "Mouse Gesture - R,U,L,D,R". If it says anything different, you're doing something wrong. If the status bar reports that you're moving the mouse correctly, but nothing comes up, or "Unknown Gesture" appears when you release the mouse button, check you've copy-and-pasted the code into the right files, and that it's exactly as it appears on this page.

If you want to know more about customising Optimoz, this page has some info on the format used in the config files:
http://optimoz.mozdev.org/gestures/technotes/
Do note that this only gives one of the mods you need to make (the gestimp.js one) - remember to modify mozgest.properties as well.

Of course, now that the latest versions of Optimoz have built-in support for custom mouse guestures and a nifty guesture recognition UI, it's trivialy easy to add your own movements and code without even having to touch a config file.

Firstly, you'll need to go to the Optimoz installation page ( http://optimoz.mozdev.org/gestures/installation.html ) and install the latest version.

After you've restarted Mozilla, go into the preferences and navigate your way through the menus to the mouse gesture options (Probably under Advanced > Mouse gestures. If you're using Phoenix Firebird Firefox, it's under Tools > Options > Extensions > Mouse Gestures. Thanks, Damodred and MALTP.) and click the "edit mappings" button at the bottom. Click "browser" in the new dialogue that appears, and then "new". Type "RULDR" in the gesture code box (or use the neat "recognize" function to draw a square-ish lowercase "e") and change the function type to "custom". For the custom code you can either use CamTarn's Javascript as above, or the stuff below, which will search for text that's currently hihlighted.

void(q-window.getSelection();
if(q)
window._content.document.location='http://www.everything2.com/?node='+escape(q);

Either way, drop the code into the "custom Javscript code" box, give the function a name, like "Search E2", and click the OK buttons until all the option screens go away. From there, you can highlight some text, then draw a block "e" shape (right, up, left, down, right) to do the search. That's it!

Many, many Javascripts were harmed in bringing you this writeup. They had it coming.

This is what I had to type in to the javascript box to make this work. Note that I used Zerotime's method, where Mozilla will use the currently selected text.

if (window._content.document.getSelection()!=null)
window._content.document.location='http://www.everything2.com/?node='+window._content.document.getSelection();

Log in or register to write something here or to contact authors.