Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created February 22, 2013 04:23
Show Gist options
  • Save mahemoff/5010718 to your computer and use it in GitHub Desktop.
Save mahemoff/5010718 to your computer and use it in GitHub Desktop.
add/remove context menu (requires tabs permission)
chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){ //onUpdated should fire when the selected tab is changed or a link is clicked.
chrome.tabs.getSelected(null,function(tab){
if (tab.url=='http://techmeme.com/')
chrome.contextMenus.create(contextMenuSpec);
else
chrome.contextMenus.removeAll();
});
});
var contextMenuSpec = {
title: 'Add to favorites',
contexts: ['all'],
onclick: function(info, tab) {
shortenLink(info, tab, {method:'bitly'});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment