Skip to content

Instantly share code, notes, and snippets.

@renshuki
Created June 20, 2017 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renshuki/527c4b3073e17146c69ca705aede4e08 to your computer and use it in GitHub Desktop.
Save renshuki/527c4b3073e17146c69ca705aede4e08 to your computer and use it in GitHub Desktop.
This bookmarklet reveal all the alt attributes of the <img /> tags (current page only)
javascript: (function() {
function getTag(tag) {
return document.getElementsByTagName(tag);
}
function a(o, a) {
return o.getAttribute(a);
}
var images = getTag('img');
if (images.length <= 0) return;
var wrap = document.createElement('div');
var wrapCSS = 'padding:5px;position:absolute;top:0;left:0;background:#fff;border:solid #ccc 1px;z-index:999;';
var tblCSS = ' style=\'border-collapse:collapse;background:#fff;\'';
var tdlCSS = ' style=\'padding:4px;border-bottom:solid #ffffff 2px;text-align:right;\'';
var tdrCSS = ' style=\'padding:4px;border-bottom:solid #ffffff 2px;text-align:left;\'';
wrap.style.cssText = wrapCSS;
var content = '<table' + tblCSS + '>';
for (var index = 0; index < images.length; index++) {
content += (index % 2 == 0) ? '<tr bgcolor=#f6f6f6>' : '<tr bgcolor=%23f2f2f2>';
content += '<td' + tdlCSS + '><img src=' + a(images[index], 'src') + '></td><td' + tdrCSS + '>' + a(images[index], 'alt') + '</td></tr>';
}
content += '</table>';
getTag('body')[0].appendChild(wrap);
wrap.innerHTML = content;
wrap.onclick = function() {
this.parentNode.removeChild(this);
};
window.scrollTo(0, 0);
})()

Usage

  1. Open alt-checker.js file as "RAW"
  2. Select all the code
  3. Drag & Drop it in your bookmarks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment