0

I'm trying to build a chrome extension to automate tasks through custom hotkeys in Gmail.

To avoid messing with the DOM, I'm working with the existing hotkeys that Gmail provides.

An example of what I want to achieve: I want Ctrl+Shift+T to trigger the combination of 'l' 't' 'return' and 'e' hotkeys, which will mean that the email is labelled 't' and archived.

I'm starting with the most 'basic' trigger:

  • In gmail, if you type 'c', it brings the compose window. With monitorEvents, you can see the keydown, keypress, keyup events triggered.
  • I've tried many different approaches (jquery, JS only, chrome debugger API... ) but I'm not able to trigger the event. I get no error.
  • I've also tried other websites like github.com and 's' to trigger search and no result either.

Any suggestions?

Community
  • 1
  • 1
deco
  • 1
  • Github's js code checks `event.target` in its `keydown` handler, which can't be spoofed. I guess gmail does the same, so you're out of luck. – wOxxOm Aug 14 '16 at 13:01
  • Depending on the element you trigger from, you set the target, right? `document.querySelector("body.logged-in.env-production.macintosh.page-dashboard").dispatchEvent(a);` sets the target correctly – deco Aug 14 '16 at 14:02
  • Set breakpoints inside the site's js code, dispatch an event from a console and see what happens, why it's rejected. – wOxxOm Aug 14 '16 at 15:19

0 Answers0