Add js/contextmenu.js

This javascript file uses chrome's API to add one or two context menu entries.
Most of the time, the shortenFile will not be called, but it is available

Signed-off-by: David Todd <c0de@unps.us>
This commit is contained in:
David Todd 2015-03-13 20:53:35 -05:00
parent 1e1f4104b7
commit 01d2275d91
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
chrome.contextMenus.onClicked.addListener(function(info, tab) {
switch(info.menuItemId) {
case "shortenLink":
shortenURL(info.linkUrl, tab.id);
break;
case "shortenFile":
shortenURL(info.srcUrl, tab.id);
break;
}
});
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({"title": "Shorten link to this file with fox.ci", "contexts": ["image", "video", "audio"], "id": "shortenFile"});
chrome.contextMenus.create({"title": "Shorten link with fox.ci", "contexts": ["link"], "id": "shortenLink"});
});