1
0
mirror of https://github.com/gamaio/lobli.git synced 2025-01-03 15:52:42 +00:00
lobli/lob.li crx/js/contextmenu.js
David Todd 371b00f452
Create the context menu when chrome starts.
This should fix a bug I've been experiencing where the context menu would not exist until I uninstall the extension and install it again from the chrome webstore
2014-12-09 14:38:55 -06:00

21 lines
874 B
JavaScript

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 lob.li", "contexts": ["image", "video", "audio"], "id": "shortenFile"});
chrome.contextMenus.create({"title": "Shorten link with lob.li", "contexts": ["link"], "id": "shortenLink"});
});
chrome.runtime.onStartup.addListener(function(){
chrome.contextMenus.create({"title": "Shorten link to this file with lob.li", "contexts": ["image", "video", "audio"], "id": "shortenFile"});
chrome.contextMenus.create({"title": "Shorten link with lob.li", "contexts": ["link"], "id": "shortenLink"});
});