johnpbloch / De-T-Co

No more t.co!
2 stars 3 forks source link

Only works for some links #3

Open rugk opened 8 years ago

rugk commented 8 years ago

This is a restartless add-on, but in my case it did not work without a Firefox restart.

STR:

  1. Open Twitter.
  2. Install Add-on.
  3. Reload Twitter page.
  4. Hover over link.

--> It is still a t.co link.

johnpbloch commented 8 years ago

I just tested this and it is currently working as expected. I think the discrepancy is that the add-on is unable to convert the links around twitter cards at the moment; rather it only works on the links themselves. I'll upload an example of what I mean.

johnpbloch commented 8 years ago

image

1: This link does get converted, and does so without restarting FF. 2: This link does not get converted. I've been looking for a way to also convert these cards' links, but haven't found a way yet. 3: this kind of card is where that becomes a problem. When the embedded card's link is the last thing in the tweet, twitter removes the link from the text, so there's nothing for de-t-co to convert. Fortunately, they're only hiding the text link, so I think it would be easy to un-hide it.

rugk commented 8 years ago

BTW: Maybe you can get some ideas from alternative add-ons: https://github.com/albancrommer/skiptco/

rugk commented 8 years ago

Okay, AFAIK Skiptco also does not work for cards: https://github.com/albancrommer/skiptco/issues/7

rugk commented 8 years ago

FYI this add-on also does not work for iframes (e.g. embedded videos and so on).

johnpbloch commented 8 years ago

The problem with trying to parse the links inside cards is that they don't have any of the expanded url info that the extension relies on to expand links. Normal links use data attributes that have the original url contained in them, which lets the extension swap them into the href attribute. Cards don't contain the expanded URL anywhere inside their document markup. Without trying to break out of the iframe and communicate with the parent frame (which may not even be possible, depending on domains being used), there's simply not enough information there to work with.

The only alternative would be to send a HEAD request to each card's t.co address to sniff the Location header. I don't really think that's a viable solution as it could easily slow the page to a crawl due to many unnecessary and slow requests just to figure out the redirect.

I'll look into videos and see if they have any data attributes to store the expanded URLs. Do you have any other specific examples of iframes that aren't working as expected.

Also, thanks for the suggestion to look into skiptco. It's always nice to be able to draw inspiration from what others have done. I'll take a look and see what improvements might be there.

rugk commented 8 years ago

The only alternative would be to send a HEAD request to each card's t.co address to sniff the Location header. I don't really think that's a viable solution as it could easily slow the page to a crawl due to many unnecessary and slow requests just to figure out the redirect.

I agree. Additionally it defeats the purpose of skipping/not accessing this t.co links as they would be accessed too anyway.

I'll look into videos and see if they have any data attributes to store the expanded URLs. Do you have any other specific examples of iframes that aren't working as expected.

Except of YouTube and Vimeo I think you can also embed gifs and other things.

eiland-asbl commented 8 years ago

I agree. Additionally it defeats the purpose of skipping/not accessing this t.co links as they would be accessed too anyway.

Depends how you define the purpose. For providing tracking anonymity for people who eventually do click - or not - a tweeted link, these head request would send Twitter into the woods sufficiently.

rugk commented 8 years ago

these head request would send Twitter into the woods sufficiently.

Yeah, in some kind, but IMHO it's not a fair way to trigger unnecessary fake request...

rugk commented 8 years ago

FYI: https://github.com/albancrommer/skiptco/commit/011023a710dfa7b7760edda3a08883d47b9f53d8