Detox

This is an intervention. Detox is a tiny Safari extension that automatically expands shortened t.co links on the Twitter site (third-party desktop app users are out of luck, sorry should see the 1.1 update below).

Ever wonder why links you find via Twitter don’t show up in your browser history and aren’t suggested by autocomplete in the url bar? The t.co link shortener serves known browser user agents an HTML page containing a JavaScript or meta refresh redirect (instead of the standard Location header) so that Twitter can stake itself out as the referrer when coming from third-party clients. This confuses Safari.

Stats are cool and all but only when they don’t break the experience for your users.

Download Detox.

(Zackary Corbett made a Chrome version too, which may or may not be necessary. Firefox and Opera also appear to be unaffected.)

Detox 1.1

Now when you hit a t.co redirect page (from a native client or a direct message from Mail.app) the destination url is added to the document title making the destination url appear in your history and url autocomplete suggestions.

Detox 1.2

Added code submitted by Orangenhain that fixes a similar history-breaking problem on Google’s search results.

Detox 1.2.1

Recently Twitter updated their link expansion data attributes. Previously the expanded url could be found in each link’s data-expanded-url attribute. A recent update duplicates the t.co url in data-expanded-url and puts the true url in data-ultimate-url.

Detox 1.2.2

Digging deeper it appears that data-ultimate-url contains the terminal for twice (or more) shortened urls (eg. a t.co’d bit.ly pointing to the terminal google.com). Detox 1.2.2 Uses data-ultimate-url if available, falling back on the original data-expanded-url. data-expanded-url containing the t.co instead of the expanded url may have just been a temporary Twitter bug. I regret jumping to conclusions but with twice shortened urls the user never sees the intermediate url which is what ultimately lead to the confusion.

Detox 1.2.3

Updated to address changes in Google’s markup. No longer relies on a class name so it should be more future proof.

Detox 1.2.4

Google (relatively?) recently made a change to their image search results markup. This update removes code that broke inline image preview as a result of this change.

Previous
Stock
Next
Lift Off: The Last Rocket Development Diary
Author
Shaun Inman
Posted
January 19th, 2012 at 4:35 pm
Categories
Apple
JavaScript