GitXplorerGitXplorer
a

highlight-twitter-alt-text

public
27 stars
4 forks
1 issues

Commits

List of commits on branch main.
Verified
45c704aa9a39f49d36e68946abb57777e82bfdc5

Update README.md

aalexwlchan committed 3 years ago
Unverified
14f3029b6ccdd5067fbe79e710324fed77bdc38e

Add a quick bookmarklet for showing alt text in a popup

aalexwlchan committed 3 years ago
Unverified
63ba5f849b4901ce3edc390364a44f518a47e1d4

display the alt text on hover

aalexwlchan committed 3 years ago
Unverified
51e428c10d7b0a93236cb18b80d4ba6237573820

Let's tweak this CSS a little

aalexwlchan committed 4 years ago
Unverified
9dfaa85d2a8db8990596cd2b1debf240db1f5f1e

s/idea/ideas

aalexwlchan committed 4 years ago
Unverified
873f2826db1a830ece46db4df2d3b758c19aaae4

Make this screenshot smaller

aalexwlchan committed 4 years ago

README

The README file for this repository.

highlight-twitter-alt-text

This repo has some tools I use to highlight the (in)accessibility of my Twitter timeline.

Motivation

Twitter supports adding alt text to images, so they're accessible to more people -- in particular, people who are blind or low-vision, who often use screen readers.

I try to remember to add alt text to every image that I post, and I'm trying not to retweet/quote tweet images that don't have alt text -- but Twitter doesn't make this easy. The alt text isn't shown if you're not using a screen reader, so at a glance it's not obvious if a particular image does or doesn't have alt text.

This repo contains a couple of CSS and JavaScript snippets I use to make alt text more visible, or hide tweets that don't include it.

Inspiration

I didn't come up with these ideas -- I saw some tweets from @lunasorcery and @thingskatedid that put the idea in my head, and I created this GitHub repo so I had something I could easily link "here's how to highlight alt text on Twitter".

Tools

Show alt text on hover with CSS

I have a couple of CSS snippets that will highlight the presence/absence of alt text. One adds an overlay that shows the alt text on the image when you hover over the image, the other dims images that don't have any:

Screenshot of a tweet with an image. At the top of the image, there's a black overlay with white text showing the alt text for the image. A tweet using add_alt_text_overlay.css Screenshot of a tweet with an image.  The image has been heavily dimmed, so it's mostly white. A tweet using dim_media_without_alt_text.css

I include both of these snippets in my browser's custom stylesheet on my desktop, so it applies everywhere on Twitter.

Hide tweets that don't have alt text

If you want to completely ignore tweets that don't include alt text, look at dim_tweets_without_alt_text.js. This includes a function that will hide all the inaccessible tweets on a timeline, so you can scroll past them quickly.

Here's what that looks like in practice:

A thread with two tweets. Both tweets have a photo of a black cat; the first tweet is shown with an alt text overlay, the second is heavily dimmed, so it's practically illegible.

This JS is a prototype; I haven't added it to my browser yet. I wrote it after a suggestion from Kate, when I thought of a neat trick for how you'd do this. You need to run it in a loop, because new tweets get added to the page as you scroll, and you want the function to pick them up.

Show alt text in a dialog box

I mostly use Twitter on my phone, which doesn't have hover states or a particularly easy way to inject custom CSS -- but it does support bookmarklets. I've written a bookmarklet which displays a dialog box showing me the alt text in any images it can find:

Screenshot of mobile web browser with a dialog box saying 'Alt text. Image 1: (no alt text). Image 2: (no alt text). Image 3: (no alt text). A tweet with no alt text using show_alt_text_in_dialog.js Screenshot of mobile web browser with a dialog box saying 'Alt text. Image 1 … Image 2 … Image 3' followed by several sentences of description. There's a scroll bar showing the alert continues off the bottom. A tweet with alt text using show_alt_text_in_dialog.js

I designed this bookmarklet to work in Safari on iOS, but it should be possible to make work in other browsers.

There's a bug where sometimes the alert doesn't fire -- reloading the page seems to fix it.