Skip to content

Instantly share code, notes, and snippets.

@pastak
Created September 22, 2013 16:12
Show Gist options
  • Select an option

  • Save pastak/6661409 to your computer and use it in GitHub Desktop.

Select an option

Save pastak/6661409 to your computer and use it in GitHub Desktop.
ConnectMessenger.bind('create_context_menu', function(event, data, port) {
chrome.contextMenus.removeAll();
if(data.type == 'default'){
chrome.contextMenus.create({
'title':'default menu',
'contexts':["page", "frame", "editable", "image", "video", "audio"],
'onclick':function(info, tab) {
alert('default');
}
});
chrome.contextMenus.create({
'title':'select "%s"',
'contexts':['selection'],
'onclick': function(info, tab) {
alert('select');
}
})
} else {
chrome.contextMenus.create({
'title':'link menu',
'contexts':['link'],
'onclick':function(info, tab) {
window.open(info.linkUrl);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment