[Greasemonkey] Greasemonkey 0.4 attempt II

Jeremy Dunck jdunck at gmail.com
Wed Jul 6 23:36:29 EDT 2005

On 7/6/05, Jason Green <jason at everydayjones.com> wrote:
>  Where can I learn more about doing this? Because basically I have no idea
> what you just said.
>  -Jason Green

OK, well the example script Aaron included is a good place to start:

window.addEventListener("click", function(e) { //hook all click events
for the window
  if (e.target.tagName.toLowerCase() == "a") { //check if the event
was targetting a link
    GM_openInTab(e.target.href); //open the link in a tab instead of normal.
    e.preventDefault(); //don't let the browser do it's normal thing
with the event.
}, false); //don't capture events 

Capturing events is something worthy of a longer explanation, but I
don't think I'm the best one to explain it.

So.. What I was saying was, go ahead and hook your event, then check
whether your option keys are depressed:



So, assuming you wanted to capture Ctrl-Alt clicks on links:

window.addEventListener("click", function(e) {
  if (e.target.tagName.toLowerCase() == "a" && e.altKeyArg && e.ctrlKeyArg) {
}, false);

More information about the Greasemonkey mailing list