Replace Twitter Embeds with Semantic HTML


I logged into Twitter using a fresh account last week. No followers, no preferences set. The default experience was an unending slurry of racism and porn. I don't care to use Twitter any more. Whatever good that was there is now drowned in a cess-pit of violent filth.

I still have a lot of Tweets embedded on this blog. Using WordPress, it was easy to paste in a link and have it converted to an embed. But I don't want to direct people to a dangerous site.

So here's a somewhat automated way to replace embedded Tweets with good-looking and semantic HTML. You no longer need to worry about Twitter tracking people if they visit your site. It in-lines all images and avatars so there's no data leakage. Links go direct rather than through the obnoxious t.co service. The HTML is semantic, short, and accessible.

The simple Python code is available on GitHub - feedback welcome!

Demos

Here are some examples. You'll see all the links work - to external sites, hashtags, or mentions. Media is loaded, emoji work, alt text is included where available, and the CSS is roughly right. The number of likes and replies is shown - but the number of retweets isn't always available in the embed API. The number of quotes and bookmarks aren't available.

Polls

Embedded Images

Quote Tweets

Replies

Videos

The poster of the video is embedded - the actual MP4 is still loaded off Twitter's site.

Get The Code

The simple Python code is available on GitHub - feedback welcome!


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

5 thoughts on “Replace Twitter Embeds with Semantic HTML”

  1. said on gotosocial.grnwds.uk:

    @Edent With regard to the algorithmic quality, my wife has very few connections on Facebook and only really uses it to read my daughter's school year message group, and if she looks at her FB feed, it's also full of appalling material, which makes me wonder about the way that the mechanism handles low information input, but not enough to want to dive into various trenches to examine it.

    Reply | Reply to original comment on gotosocial.grnwds.uk

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">