Find out how to Detect Failed Requests through Net Extensions

Find out how to Detect Failed Requests through Net Extensions

The most effective issues that ever occurred to t he person expertise of the online has been internet extensions. Browsers are highly effective however extensions convey a brand new stage of performance. Whether or not it is crypto wallets, media gamers, or different standard plugins, internet extensions have develop into important to on daily basis duties.

Engaged on MetaMask, I’m thrust right into a world of constructing every thing Ethereum-centric work. A kind of functionalities is guaranteeing that .eth domains resolve to ENS when enter to the deal with bar. Requests to https://vitalik.ethnaturally fail, since .eth is not a natively supported prime stage area, so we have to intercept this errant request.

// Add an onErrorOccurred occasion through the browser.webRequest extension API
browser.webRequest.onErrorOccurred.addListener((particulars) => {
  const { tabId, url } = particulars;
  const { hostname } = new URL(url);

  if(hostname.endsWith('.eth')) {
    // Redirect to wherever I need the person to go
    browser.tabs.replace(tabId, { url: `https://app.ens.domains/${hostname}}` });
  }
},
{
  urls:[`*://*.eth/*`],
  varieties: ['main_frame'],
});

Net extensions present a browser.webRequest.onErrorOccurred technique that builders can plug into to hear for errant requests. This API does not catch 4** and 5** response errors. Within the case above, we search for .eth hostnames and redirect to ENS.

You possibly can make use of onErrorOccurred for any variety of causes, however detecting customized hostnames is a good one!

  • An Interview with Eric Meyer

    Your early CSS books had been instrumental in pushing my love for entrance finish applied sciences. What was it about CSS that you just fell in love with and drove you to jot down about it? At first blush, it was the simplicity of it as in comparison with the table-and-spacer…

  • Serving Fonts from CDN

    For optimum efficiency, everyone knows we should put our belongings on CDN (one other area).  Together with these belongings are customized internet fonts.  Sadly customized internet fonts through CDN (or any cross-domain font request) do not work in Firefox or Web Explorer (appropriately so, by spec) although…


rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.