Hacker News new | ask | show | jobs
by treyp 5645 days ago
kind of. it's not done on the front end (js) but rather using some service on the backend.

the phrasing of that is a bit weird, but they probably test until they no longer get a 301 or 302 redirect and save the result. they print this result on the front end as a title for the link and as an HTML5 data attribute "expanded-url" on the link.

1 comments

I looked at doing this using Javascript in a browser extension a while ago, and it's actually not possible to do for a couple of reasons:

  1) XHR cross domain policy prohibits requests to domains other than the domain the page loaded from
  2) the XHR GET method always follows a 301 redirect and returns the content at the URL.  The full URL is not made available.
You'd have to write something on your server that does this, and expose it to your client JS via a local URL.