Created
September 8, 2020 19:04
-
-
Save pravdomil/be27dcdb284b5fe25d50919f90420964 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
function getCssElmClasses() { | |
const a = [...document.styleSheets] | |
.map((b) => [...b.cssRules]) | |
.flat() | |
.map((b) => b instanceof CSSMediaRule ? [...b.cssRules] : [b]) | |
.flat() | |
.map((b) => b.selectorText) | |
.filter((b) => b) | |
.map((b) => b.split(",")) | |
.flat() | |
.map((b) => b.trim()) | |
.filter((b) => b.match(/^\./)) | |
.map((b) => b.replace(/^\.([a-zA-Z0-9_-]*).*$/, "$1")) | |
.map((b) => `${b.replace(/-./g, (c) => c.substr(1).toUpperCase())} = class ${JSON.stringify(b)}`) | |
return [...new Set(a).keys()].join("\n") | |
} | |
document.write(getCssElmClasses().replace(/\n/g, "<br>")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment