The right way to Detect Failed Requests through Net Extensions

[ad_1]

Top-of-the-line issues that ever occurred to t he consumer expertise of the online has been net extensions. Browsers are highly effective however extensions deliver a brand new degree of performance. Whether or not it is crypto wallets, media gamers, or different widespread plugins, net extensions have turn out to be important to on daily basis duties.

Engaged on MetaMask, I’m thrust right into a world of constructing the whole lot Ethereum-centric work. A type of functionalities is guaranteeing that .eth domains resolve to ENS when enter to the tackle bar. Requests to https://vitalik.ethnaturally fail, since .eth is not a natively supported prime degree 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 consumer to go
    browser.tabs.replace(tabId, { url: `https://app.ens.domains/${hostname}}` });
  }
},
{
  urls:[`*://*.eth/*`],
  varieties: ['main_frame'],
});

Net extensions present a browser.webRequest.onErrorOccurred methodology 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 might make use of onErrorOccurred for any variety of causes, however detecting customized hostnames is a superb one!

  • 5 Ways that CSS and JavaScript Interact That You May Not Know About
  • Convert XML to JSON with JavaScript
  • CSS 3D Folding Animation
  • Highlight Table Rows, Columns, and Cells Using MooTools 1.2.3

    Row highlighting and particular person cell highlighting in tables is fairly easy in each browser that helps :hover on all parts (principally the whole lot besides IE6). Column highlighting is a little more tough. Fortunately MooTools 1.2.3 makes the method straightforward. The XHTML A traditional desk. The cells…


[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *