focus form items by following

This commit is contained in:
Shin'ya Ueoka 2017-09-17 18:21:07 +09:00
parent ba2022c465
commit 324cf32c5b
3 changed files with 33 additions and 19 deletions

View file

@ -11,11 +11,32 @@ consoleFrames.initialize(window.document);
const startFollows = (newTab) => {
let follow = new Follow(window.document, newTab);
follow.onActivated((element) => {
browser.runtime.sendMessage({
type: messages.OPEN_URL,
url: element.href,
newTab
});
switch (element.tagName.toLowerCase()) {
case 'a':
return browser.runtime.sendMessage({
type: messages.OPEN_URL,
url: element.href,
newTab
});
case 'input':
switch (element.type) {
case 'file':
case 'checkbox':
case 'radio':
case 'submit':
case 'reset':
case 'button':
case 'image':
case 'color':
return element.click();
default:
return element.focus();
}
case 'textarea':
return element.focus();
case 'button':
return element.click();
}
});
};