Source code for bookmarklet Show ALT.
javascript:
(function(){
function cE(a)
{
var a2 = [];
for (var k = 0; k < a.length; ++k) {
a2.push(a[k]);
}
return a2;
}
function hasAttribute(e, a)
{
return e.hasAttribute(a);
}
var rp = 0;
var ic = 0;
function eD(dt) {
var c = cE( dt.images );
for (var k = 0; k < c.length; ++k) {
var img = c[k];
var alt = img.alt;
var noalt = !hasAttribute(img, "ALT");
++ic;
rp += (noalt ? 1 : 0);
var s = dt.createElement( "SPAN" );
s.appendChild(
dt.createTextNode( noalt ? "[IMG_" + ic + "]" : alt)
);
s.title = img.src;
img.parentNode.replaceChild(s, img);
}
alert("ALT-less items: " + rp + "/" + ic);
}
// "dIr" == "documentIterator"
function dIr(dt, f) {
function ifsr( fs )
{
for (var i = 0; i < fs.length; ++i)
{
try {
dIr(fs[i].contentDocument, fs[i]); // recursive call
}
catch (e) {
alert(e || "Unspecified error");
}
}
}
if (dt == null) {return;}
eD(dt, f);
ifsr( dt.getElementsByTagName("FRAME") );
ifsr( dt.getElementsByTagName("IFRAME") );
}
// iterate through all documents
dIr(document, null);
}());