Skip to content

Instantly share code, notes, and snippets.

@ubershmekel
Last active April 23, 2018 09:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubershmekel/2fb69d70e0a8a1ff4e823c2e5378533c to your computer and use it in GitHub Desktop.
Save ubershmekel/2fb69d70e0a8a1ff4e823c2e5378533c to your computer and use it in GitHub Desktop.
See alt descriptions js console snippet
// Paste the following into your js console while viewing images, e.g. on your facebook feed.
// It will show the "alt" attributes that facebook assigned your images.
// It's an interesting peek into how facebook analyzes your images.
setInterval(function() {
var imgs = document.querySelectorAll("img");
for (var i = 0; i < imgs.length; i++) {
var alt = imgs[i].alt;
if (alt && !imgs[i].getAttribute("alted")) {
var div = document.createElement("div");
div.append(document.createTextNode(alt));
div.setAttribute("style", "position: absolute; top: 0; left: 0; z-index: 100; text-shadow: 0 0 4px #000; color: #fff;font-weight: bold;");
imgs[i].parentElement.prepend(div);
imgs[i].setAttribute("alted", "1");
}
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment