Open url in microsoft edge (context menu)

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);

});

Please use “preformated text” to make your code more readable.
It’s the </> symbol.

And if you upload your extension somewhere, we can play around with it :slight_smile:

If I submit this in the Web Console for an example page, like this one, Firefox prompts me to allow it, and then Edge opens or focuses but doesn’t seem to receive the URL or doesn’t act on it:

location.href = location.href.replace(new RegExp("^.*//"), 'microsoft-edge://');

Where is the documentation on how this protocol works?

The idea is based on these extensions -

Open tab in MS Edge

Open in Microsoft Edge

ff2mpv (for Windows)

My intention is to have this action in the contentAreaContextMenu, not via a toolbar icon.

As for the URL protocol itself; it’s located here -
HKEY_USERS\S-1-5-21-1603810768-1890691689-965554032-1001\SOFTWARE\Classes\microsoft-edge

Based on one of those, you need to keep the protocol. In other words:

location.href = 'microsoft-edge:' + location.href;