- Open alt-checker.js file as "RAW"
- Select all the code
- Drag & Drop it in your bookmarks
Created
June 20, 2017 16:09
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment