I am experimenting with an extension that will open any focused page in Firefox with Microsoft Edge from the CONTEXT MENU.
The intention is to utilise the existing microsoft-edge URL Protocol in Windows instead of a native client.
The background.js code below does in fact open Edge but only as a New Tab page and not the intended URL from Firefox.
I’m relatively new to JavaScript so any assistance would be appreciated.
function ff2edge(url) {
var link = url.replace(new RegExp("^.*//"),“microsoft-edge://”)
browser.tabs.executeScript({
code: window.location = "
+ link + ";
});
}
browser.contextMenus.create({
id: “ff2edge”,
title: “Open with Microsoft Edge”
});
browser.contextMenus.onClicked.addListener((info, tab) => {
switch (info.menuItemId) {
case “ff2edge”:
url = info.linkUrl || info.frameUrl || info.pageUrl;
if (url) ff2edge(url);
break;
}
});
browser.browserAction.onClicked.addListener((tab) => {
ff2edge(tab.url);
});