Skip to content

Instantly share code, notes, and snippets.

@pedroha
Created June 28, 2013 18:29
Show Gist options
  • Save pedroha/5886899 to your computer and use it in GitHub Desktop.
Save pedroha/5886899 to your computer and use it in GitHub Desktop.
Retrieve color palettes from Adobe Kuler. 1) Visit: https://kuler.adobe.com/explore/most-favorite/ 2) Open command console and copy/paste the code.
var getPaletteColors = function () {
var $items = $('div.collection-assets-item > .content');
var palette = [];
$items.each(function () {
var self = this;
var $frame = $('.frame', this);
var colors = [];
$('.frame > div', this).each(function () {
var style = $(this).attr('style');
var color = style.substr('background: '.length);
colors.push(color);
});
// console.log(colors);
palette.push({
colors: colors
});
});
var metadata = [];
$items.each(function () {
var self = this;
$('.assets-item-meta a', self).each(function () {
var $link = $(this);
var data = {
name: $link.text()
// href: $link.attr('href')
// , name: $link.text()
};
// console.log(data);
metadata.push(data);
});
});
for (var i = 0; i < metadata.length; i++) {
metadata[i].colors = palette[i].colors;
}
var output = JSON.stringify(metadata);
output = output.replace(/},{/g, '},\n{');
output = output.replace(/#/g, '');
return output;
};
var out = getPaletteColors();
console.log(out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment