Skip to content

How you can Come across Failed Requests by means of Internet Extensions


Probably the most perfect issues that ever came about to t he person enjoy of the internet has been internet extensions. Browsers are tough however extensions deliver a brand new degree of capability. Whether or not it is crypto wallets, media avid gamers, or different widespread plugins, internet extensions have turn out to be very important to each day duties.

Running on MetaMask, I’m thrust into a global of creating the entirety Ethereum-centric paintings. A type of functionalities is making sure that .eth domain names get to the bottom of to ENS when enter to the cope with bar. Requests to https://vitalik.ethnaturally fail, since .eth is not a natively supported most sensible degree area, so we want to intercept this errant request.

// Upload an onErrorOccurred tournament by means of the browser.webRequest extension API
browser.webRequest.onErrorOccurred.addListener((main points) => {
  const { tabId, url } = main points;
  const { hostname } = new URL(url);

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

Internet extensions supply a browser.webRequest.onErrorOccurred manner that builders can plug into to pay attention for errant requests. This API does now not catch 4** and 5** reaction mistakes. Within the case above, we search for .eth hostnames and redirect to ENS.

It’s worthwhile to make use of onErrorOccurred for any collection of causes, however detecting customized hostnames is a brilliant one!

  • 5 Ways that CSS and JavaScript Interact That You May Not Know About
  • How I Stopped WordPress Comment Spam

    I like nearly each a part of being a tech blogger:  studying, preaching, bantering, researching.  The only phase about running a blog that I completely detest:  coping with SPAM feedback.  For the previous two years, my weblog has registered 8,000+ SPAM feedback according to day.  PER DAY.  Bloating my database…

  • Fullscreen API

    As we transfer towards truer internet packages, our JavaScript APIs are doing their perfect to maintain.  One quite simple however helpful new JavaScript API is the Fullscreen API.  The Fullscreen API supplies a programmatic method to request fullscreen show from the person, and go out…

  • CSS Custom Cursors

    Bear in mind the Internet 1.0 days the place you needed to customise your web page in each means conceivable?  You abused the scrollbars in Web Explorer, in fact, however the most well liked exterior carrier I will be mindful used to be CometCursor.  CometCursor permit you to create and use plenty of customized cursors for…

Ready to get a best solution for your business?