3

I have a old addons to Firefox that registry a custom protocol "linkpassword://"

Since Firefox Version 57 the addon stop working and I have to rewrite the full addons as a Firefox WebExtenstion.

My issue is I can't find a way to registry a handler for protocol "linkpassword://".

FIG-GHD742
  • 2,486
  • 1
  • 19
  • 27

2 Answers2

2

The "protocol_handlers" section in the manifest.json of your Firefox WebExtensions can be used to register a common or a custom protocol handler.

But from the documentation at MDN WebExtensions protocol_handlers it seems like you have to prefix a custom protocol handler with web+something or ext+something.

You can process the link in your extension by just using a page in your extension as "uriTemplate" like this:

"protocol_handlers": [
    {
        "protocol"   : "ext+linkpassword",
        "name"       : "Password Link",
        "uriTemplate": "html/processLink.html#login=%s"
    }
],
MDW
  • 76
  • 6
1

Currently, you can't register a handler for linkpassword:// with WebExtensions.

As for now only the specified whitelisted protocols are allowed to be used without a prefix (one of bitcoin, geo, gopher, im, irc, ircs, magnet, mailto, mms, news, nntp, sip, sms, smsto, ssh, tel, urn, webcal, wtai, xmpp). Any other custom name requires to be prefixed with either web+ or ext+. See protocol_handlers reference.

With the prefix you can register it this way:

"protocol_handlers": [
    {
        "protocol"   : "ext+linkpassword",
        "name"       : "Password Link",
        "uriTemplate": "html/processLink.html#login=%s"
    }
],

Then you'll have to use ext+linkpassword:// in your links to trigger the handler.

While with the current state of WebExtensions you can't set a handler for an arbitrary protocol, like linkpassword://, it is likely to change at some point, since there are some discussions about it, but it's hard to say when to expect this. As a temporary workaround before the real solution is available you can patch linkpassword:// to ext+linkpassword:// on the web page with your WebExtension JS code so that the handler is still triggered even if the links on the page were loaded with the linkpassword:// schema.

senya
  • 984
  • 12
  • 20