Skip to content

Instantly share code, notes, and snippets.

@Snarp
Forked from AprilSylph/exposeClassKeys.js
Created April 4, 2023 00:05
Show Gist options
  • Save Snarp/e33d5083724307a51ce329a658eb6fff to your computer and use it in GitHub Desktop.
Save Snarp/e33d5083724307a51ce329a658eb6fff to your computer and use it in GitHub Desktop.
expose source names on Tumblr
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(`tumblr--${mappedClassName}`);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment