I am working on a chrome extension that function nearly the same as open in new tab, but "open in new tab" apparently does not allow open links for intranet files such as file:// due to chrome security reasons. Therefore, by having this extension, the users who has this custom extension will be able to open the url link.
I managed to put something where when i select any part of the link text, then i right click to contextmenu, it is able to open the link in new tab. What i want now is to be able to right click the link without selecting the text.
I have tried changing the contexttype to link, but it doesn't seem to work.
Here is the background.js code that does the selection then open in new tab.
I hope maybe someone can shed some ideas and maybe snippet code as to what i can do here to keep me rolling.
background.js
var context = "selection";
var title = "Open Local File";
var id = chrome.contextMenus.create({
"title": title,
"contexts":[context],
"id": "context" + context}
);
// add click event
chrome.contextMenus.onClicked.addListener(onClickHandler);
function onClickHandler(info, tab) {
var sText = info.linkUrl;
var myUrl = sText;
chrome.tabs.create({ url: myUrl });
};
manifest.json
{
"name": "Right-click context sample",
"description": "sample",
"version": "0.0.1",
"permissions": ["contextMenus", "tabs", "<all_urls>"],
"background": {
"page" : "background.html",
"persistent": false
//"scripts": ["background.js"]
},
"manifest_version": 2
}
Thanks!