Skip to content

Instantly share code, notes, and snippets.

@jomifepe
Last active June 12, 2021 15:24
Show Gist options
  • Save jomifepe/3dec3e199240e2e07c7310159f721996 to your computer and use it in GitHub Desktop.
Save jomifepe/3dec3e199240e2e07c7310159f721996 to your computer and use it in GitHub Desktop.
Simple script to get all HTML colors from w3schools as a TypeScript enum (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 enumString = 'export enum HtmlColor {\n' + colors.map((color) => `\t${color} = '${color}'`).join(',\n') + ',\n}';
console.log(enumString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment