Reputation: 1
I've got the context.menu working correctly. I just don't want it to show whenever I select something other than an IP address. I have the code for validating a IP address just don't know how to implement this.
I know that chrome will add context.menus when you select hostnames and ip addresses and add "go 98.223.234.2xx" or "go cnn.com". How is chrome doing this?
Upvotes: 0
Views: 199
Reputation: 4115
One thing you can try is
Use mouseup
and keypress
event listeners for mouse and keyboard selection, respectively.
Use window.getSelection()
to get the selection, and compare it with the IP address you want.
If the selection matches the IP address, you can create the menu by
chrome.contextMenus.create({
"title" : "menuTitle",
"contexts" : ["selection"]
});
Upvotes: 1