Tell HN: Chrome DevTools protocol has begun providing the faviconUrl

This is good news. If you want to build a browser or some other similar experience atop this protocol you had to fish around for the favicon URL yourself, which while it might sound trivial is not always easy.

This is because it might be one of:

- /favicon.ico

- the first successful /link[rel=icon].href

But what if favicon.ico serves with 200 but is an invalid image? Same goes for the icon link elements. Including that sometimes, you can't just pull the data from within the page's JS context using fetch/xhr due to CORS.

So, you need to send the favicon url to the server for fetching, but ensure you have the right browser headers and in some cases cookies etc! Hahah :)

So, serving up the expected favicon is not always trivial. Hahaha! :) Having a canonical url that the browser thinks is right will save a lot of hassle.

Of course, caveats around the response validity are still true, but it's good news or seems so.

Now to obtain this, run Chrome with a remote debugging port and point it at that some URL. Then just curl /json/version on the protocol backend, like so:

  google-chrome-stable --remote-debugging-port=9993 
  curl http://localhost:9992/json
You should see (in latest) a `faviconUrl` field for any page targets returned! :)

1 points | by keepamovin 13 days ago

0 comments