[Greasemonkey] [Help]How to replace an js method or event?

Bill Donnelly donnelly at snowcrest.net
Thu Oct 6 12:04:12 EDT 2005


[rant]
In what is probably (one of) the worst failings of Firefox/Mozilla
since the beginning, mouse and keyboard values and states are not
available to the JS programmer whenever s/he wants them, like via
the IE event.keyCode, for example, but only during the associated
events when they fire.

Even the most basic languages almost always give you access to
these values, and it's kind of sad that IE does, and Ffx does not.
And I wouldn't hold my breath for this functionality if I were
you, either. At best, maybe someone will write an extension that
gives this functionality to programmers, although that is a problem
when someone doesn't have the extension installed, rather than the
functionality being part of the defalt DOM, JS extensions, etc.
So that sort of thing stops wide use, anyway.

I know they all like to have their little feature wars, on both/all
sides of the coin, but all it does make it hard on programmers,
and make X-platform programming a major pain in the ass. It would
be nice if they would just all grow the hell up and give us stuff
that IE has, and vice versa. Even if it was a pref you had to
toggle for strict or xplatform compatability.
[/rant]

ANYWAY, for Gm, I created a script to give me access to these values,
which is better than nothing. Again, their use is somewhat limited,
unless you want to check for them and notify the user that they
are suggested or required and they must install Gm and/or the script
in question. I mostly use them for Bookmarklet use, where I want to
modify behaviour depending on whether the Ctrl key is pressed, and
other uses like that. I won't use some of the stuff, I just
generalized the thing on principal.

Actually, I just looked at it, and I only did the keyboard values
and not any mouse values. I don't remember why.

Here is the script, which you can use, as is, or take out the
desired parts and use them specifically in your code. The script
is still in BETA status, but seems to work fine. I have only
tested it in Gm 0.5.3 and Ffx 1.0.7-. (if anyone is using it in
1.5+, please let us know)

In retrospect, maybe I should create a special event object and
emulate the IE names and references (objects/properties/methods).
Let me know if anyone thinks that is a good/better idea.

http://www.snowcrest.net/donnelly/gmscripts/globkeywinevt.user.js

----
ALSO, if anyone wants to use my monkey icons in the Ffx browser
for the clickable status icon on the status bar, I put them up so
you can download them and store them in your Gm extension content
folder/directory.

http://www.snowcrest.net/donnelly/gmscripts/status_on.gif
http://www.snowcrest.net/donnelly/gmscripts/status_off.gif

If you don't know where content is, in Windows OS, do a file search
using your Windows\Application Data\Mozilla\Firefox directory as
the starting point and search for status_on.gif --- other OS's
do whatever is similar. You will have to reinstall them any time
you upgrade Gm.



More information about the Greasemonkey mailing list