I want to pass url to external program (open url with program), but without creating new tab/window. I used "chrome.contextMenus.create" to open url with program: right-click the link & "open with external program": http://postimg.org/image/usj1yb8gj/
I wrote next code for my chrome-extension:
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({
title: 'Open with some program',
id: 'nameOfprogram',
contexts: ['link'],
});
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId === "nameOfprogram") {
//var win = window.open("NameOfUriScheme://" + info.linkUrl, '_blank'); // '_self' - doesn't work...
chrome.tabs.create({ url: "NameOfUriScheme://" + info.linkUrl },function(tab){setTimeout(function(){chrome.tabs.remove(tab.id);}, 1000);});
}
});
But it opens new tab for 1 second to open url. Can be uri-scheme:adress (when uri associated with specific program) open without creating new tab when you opens it using contexts menu?
Omg. I just need to replace create
to update
- chrome.tabs.update({...});