Last active
January 31, 2024 02:34
-
-
Save AprilSylph/511b809ffec1f4e3b8bcb4af93c1f8cd to your computer and use it in GitHub Desktop.
expose source names on Tumblr
This file contains 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
tumblr.getCssMap().then(cssMap => { | |
const keys = Object.keys(cssMap); | |
const elements = document.querySelectorAll('[class]'); | |
for (const { classList } of elements) { | |
for (const className of classList) { | |
const mappedClassName = keys.find(key => cssMap[key].includes(className)); | |
if (mappedClassName) classList.add(`style-${mappedClassName}--${className}`); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment