Created
June 9, 2011 09:11
-
-
Save danbeam/1016396 to your computer and use it in GitHub Desktop.
Get the colors that can be optimized on the w3's CSS3 color page
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
// on http://www.w3.org/TR/css3-color/ | |
Array.prototype.forEach.call(document.querySelectorAll('table.colortable')[1].querySelectorAll('td:not(.c)'), function(td) { | |
var name = td.innerText, | |
hex = td.nextSibling.innerText; | |
if (hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) { | |
hex = '#' + hex[1]+hex[3]+hex[5]; | |
} | |
if (hex.length > name.length) { | |
console.log(hex, '->', name); | |
} | |
else if (name.length > hex.length) { | |
console.log (name, '->', hex); | |
} | |
}); | |
// save to file then | |
// awk '{printf " %-39s-> %s\n", tolower($1), tolower($3)}' < colors.css |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment