Skip to content

Instantly share code, notes, and snippets.

@Shrinks99
Created October 14, 2024 23:58
Show Gist options
  • Save Shrinks99/f18f3bf2a0e27fb00f2889063300d365 to your computer and use it in GitHub Desktop.
Save Shrinks99/f18f3bf2a0e27fb00f2889063300d365 to your computer and use it in GitHub Desktop.
Alex Chan's show alt text utility but as a bookmarklet
javascript:(function()%7Bdocument.querySelectorAll(%22img%22).forEach(function(img)%20%7Bimg.parentElement.innerHTML%20%2B%3D%20img.getAttribute('alt')%20!%3D%3D%20null%3F%20%60%3Cdiv%20style%3D%22background%3A%20lime%3B%20font-family%3A%20monospace%3B%20color%3A%20black%3B%20padding%3A%205px%3B%22%3EAlt%20text%3A%20%24%7Bimg.getAttribute(%22alt%22)%7D%3C%2Fdiv%3E%60%20%3A%20%60%3Cdiv%20style%3D%22background%3A%20red%3B%20font-family%3A%20monospace%3B%20color%3A%20white%3B%20padding%3A%205px%3B%22%3ENo%20alt%20text!%3C%2Fdiv%3E%60%3B%7D)%3B%7D)()%3B
@Shrinks99
Copy link
Author

Shrinks99 commented Oct 14, 2024

Usage instructions: Create a new bookmark and ave the full text of this gist as the URL. Clicking on it will then run the script on any page!


Created with https://caiorss.github.io/bookmarklet-maker/

See https://alexwlchan.net/2024/alt-text-snippet/ for her original post!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment