Skip to content

Instantly share code, notes, and snippets.

View NikitaRevenco's full-sized avatar

Nikita Revenco NikitaRevenco

View GitHub Profile
@NikitaRevenco
NikitaRevenco / catppuccin-cssvariable-transformer.js
Last active September 9, 2024 16:25
Catppuccin CSS Variable Getter and Transformer for websites
/**
* Retrieves all CSS custom properties (variables) from the document's style sheets.
* @returns {[string, string][]} An array of key-value pairs where the key is the CSS variable name and the value is its definition.
*/
const getAllCssVariables = () =>
[...document.styleSheets]
.filter(({ href }) => !href || href.startsWith(window.location.origin))
.flatMap(({ cssRules }) =>
[...cssRules]
.filter(({ type }) => type === 1)