Skip to content

Instantly share code, notes, and snippets.

@AprilSylph
Last active January 31, 2024 02:34
Show Gist options
  • Save AprilSylph/511b809ffec1f4e3b8bcb4af93c1f8cd to your computer and use it in GitHub Desktop.
Save AprilSylph/511b809ffec1f4e3b8bcb4af93c1f8cd 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(`style-${mappedClassName}--${className}`);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment