I have a simple Chrome extension which adds a menu entry when I right-click after selecting some text, it then uses that text to open another web page (similar to the "Search Google For..." entry).
However, I would like to be able to have the entry only active if the selected text matches a specific form. Eg, if the text is just numbers or conforms to some regular expression, since the user could highlight any arbitrary text which may not be relevant.
Is there a way to either have the menu entry show only when the text conforms? Or maybe grey the menu entry out if it doesn't conform? (I'd prefer to hide it, but this would be an acceptable alternative).