Skip to content

Instantly share code, notes, and snippets.

@jomifepe
Last active June 12, 2021 15:23
Show Gist options
  • Save jomifepe/2380e7203ca218b9f88c531a028247e2 to your computer and use it in GitHub Desktop.
Save jomifepe/2380e7203ca218b9f88c531a028247e2 to your computer and use it in GitHub Desktop.
Simple script to get all HTML colors from w3schools as a TypeScript union (https://www.w3schools.com/colors/colors_names.asp)
// Paste it on the console, while in: https://www.w3schools.com/colors/colors_names.asp
const colors = [...document.querySelectorAll('.colornamespan')].map((el) => el.textContent.toLowerCase())
const union = [...colors].reduce((acc, name) => `${acc}| '${name}'\n`, '');
console.log(union);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment