UPDATES

Find out how to Detect Failed Requests by way of Net Extensions

[ad_1]

Top-of-the-line issues that ever occurred to t he person expertise of the net has been net extensions. Browsers are highly effective however extensions carry a brand new stage of performance. Whether or not it is crypto wallets, media gamers, or different in style plugins, net extensions have grow to be important to day by day duties.

Engaged on MetaMask, I’m thrust right into a world of constructing every little thing Ethereum-centric work. A kind 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 stage area, so we have to intercept this errant request.

// Add an onErrorOccurred occasion by way of 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 would like the person to go
    browser.tabs.replace(tabId, { url: `https://app.ens.domains/${hostname}}` });
  }
},
{
  urls:[`*://*.eth/*`],
  sorts: ['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 could possibly make use of onErrorOccurred for any variety of causes, however detecting customized hostnames is a superb one!

  • Animated 3D Flipping Menu with CSS
  • Facebook Open Graph META Tags

    It is no secret that Fb has grow to be a serious site visitors driver for every type of internet sites.  These days even massive firms steer shoppers towards their Fb pages as an alternative of the company web sites straight.  And naturally there are Fb “Like” and “Suggest” widgets on each web site.  One…

  • prefers-color-scheme: CSS Media Query

    One machine and app function I’ve come to understand is the flexibility to vary between mild and darkish modes. Should you’ve ever accomplished late night time coding or studying, you understand how wonderful a darkish theme could be for stopping eye pressure and the complications that consequence.

  • Detect DOM Node Insertions with JavaScript and CSS Animations

[ad_2]

Leave a Reply

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