Created
February 22, 2013 04:23
-
-
Save mahemoff/5010718 to your computer and use it in GitHub Desktop.
add/remove context menu (requires tabs permission)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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