(no title)
h43z | 7 months ago
addEventListener('keydown', event => {
if(event.key !== 'Enter')
return
elementWithSelection = getSelection().anchorNode?.parentElement
if(!elementWithSelection)
return
elementWithSelection.click()
getSelection().empty()
})
This allows you to use the native CTRL+f and / search basically like the ' search.The ' search let's you "click" on links by pressing enter.
The snippet let's you do the same for the other searches too so you can navigate the modern web where often navigations and actions are behind buttons and sometimes even divs (not just links). Unfortunately you can't activate those without this little hack.
The extension will be available at https://addons.mozilla.org/en-US/firefox/addon/click-on-sele... soon (after mozilla approves).
I use this trick in a slightly bigger extension too https://github.com/h43z/jkscroll/blob/main/content-script.js...
No comments yet.