Created
July 7, 2025 17:31
-
-
Save nopeless/37e3559d22b2be25b7f7aff335e7322a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const classes = new Set(); | |
| document.querySelectorAll('[class]').forEach(el => { | |
| el.classList.forEach(cls => classes.add(cls)); | |
| }); | |
| const replacer = prefix => [...classes].find(c => c.startsWith(prefix)); | |
| const classRegex = /class\^=("[^"]+"|(?:\\.|[^\\\n\]])+)/g; | |
| const cssProcessor = text => text.replace(classRegex, match => `class=${replacer(match[1])}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment