diff options
Diffstat (limited to 'src/content/focuses.js')
-rw-r--r-- | src/content/focuses.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/content/focuses.js b/src/content/focuses.js new file mode 100644 index 0000000..a6f6cc8 --- /dev/null +++ b/src/content/focuses.js @@ -0,0 +1,13 @@ +import * as doms from 'shared/utils/dom'; + +const focusInput = () => { + let inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url']; + let inputSelector = inputTypes.map(type => `input[type=${type}]`).join(','); + let targets = window.document.querySelectorAll(inputSelector + ',textarea'); + let target = Array.from(targets).find(doms.isVisible); + if (target) { + target.focus(); + } +}; + +export { focusInput }; |