Skip to content

Instantly share code, notes, and snippets.

@garudamon
Created April 1, 2022 03:27
Show Gist options
  • Select an option

  • Save garudamon/42a22a514d07e8482214455d292ac8ef to your computer and use it in GitHub Desktop.

Select an option

Save garudamon/42a22a514d07e8482214455d292ac8ef to your computer and use it in GitHub Desktop.
Colors Scheme Collector
// this script is only working with:
// https://www.schemecolor.com/?s=pastel
const rgb2hex = (rgb) => `#${rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/).slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, '0')).join('')}`;
let colors = [];
document.querySelectorAll('.color-palettes-list li').forEach((ct) => {
let c = ct.querySelectorAll('.c');
let clen = c.length;
for (let i = 0; i < clen; i++) {
let rgb = window.getComputedStyle(c[i], null).getPropertyValue('background-color');
let hex = rgb2hex(rgb)
colors.push(hex);
}
});
console.log(colors);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment