philc / vimium

The hacker's browser.
https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
MIT License
23.46k stars 2.49k forks source link

Also use aria-label when matching link hints #3215

Open mpetazzoni opened 5 years ago

mpetazzoni commented 5 years ago

It would be great if Vimium also relied on the aria-label attribute when filtering link hints based on typeahead. There are some situations in which buttons or links don't have any text content, but are properly labelled for accessibility with aria-label, and those are sadly excluded from link hints filtering. A perfect example of that is the notification bell icon on GitHub itself.

I don't know much about CoffeeScript but I believe this could be done by adding:

else if element.hasAttribute "aria-label"
  linkText = element.getAttribute "aria-label"

Inside the generateLinkText function near: https://github.com/philc/vimium/blob/881a6fdc3644f55fc02ad56454203f654cc76618/content_scripts/link_hints.coffee#L852-L855.

smblott-github commented 5 years ago

I tried this (and also added the text to the label): 7f37bae4550e14ae6742a8e539eca89f7f0cbb24. Looks like this on GMail...

image

Not bad. I'll try it myself for a bit before merging.

mpetazzoni commented 5 years ago

That looks great. Did you happen to try on GitHub as well? Let me know when this gets merged in!

mpetazzoni commented 5 years ago

Ping? Would love to see this functionality make it into Vimium!