In the Chrome extension I'm working on right now, there is a situation where the user right-clicked on this link:
<a href="http://www.google.com">Hello</a>
and selected a specific option from the extension’s context menu, I need the string “Hello” to be written in some form. As the context menu API shows , it's easy to capture text with a right-click or the actual hyperlink URL (in this case Google.com), as they appear in OnClickData, but I'm not sure how to capture the text from the link.
As a note, if a user selects a hyperlink and tries to use my context menu, it does not work. However, it works correctly if the user selects plain text. I have a “link” and the “selection” is included in the “contexts” when I create a context menu option.
source
share