2

I got annoyed at how if you press tab in gmail, it will select the send button, so you keep typing and eventually it sends. I'm trying to intercept the tab key with Greasemonkey.

The window.onkeydown thing doesn't catch events when they're in the message compose box.

The box is in an iframe, and while Greasemonkey should run in iframes, I'm thinking this might be the problem?

So currently I'm just trying to find the class gmail_default, which surrounds the text in the message box, so I can attach a listener directly to that.

I do this when a key is pressed, as the compose box is not a thing that exists when the page first loads.

window.onkeydown = function(evt) {
    evt = evt || window.event;
    switch (evt.keyCode) {
        case 9:
           alert("woo");
              alert(document.getElementsByClassName("gmail_default").length);
            break;
    }
};

But this returns 0.

I have no idea where to go from here, I'm not even sure if giving up on the window.onkeydown and trying to append a listener directly to the element surrounding the text is the correct approach.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
mtfurlan
  • 1,024
  • 2
  • 14
  • 25
  • FF+GM does run in iframes, you need to wait for the object to appear and place an intercepting event listener on it. Scripting Gmail is a right PITA. – Brock Adams Mar 16 '14 at 07:36
  • @BrockAdams I am waiting for it to appear, I'm manually triggering the thing currently. – mtfurlan Mar 16 '14 at 08:21

0 Answers0