profile menu

This commit is contained in:
metacryst
2025-10-01 22:49:25 -05:00
parent a01fb24a69
commit 989dbd88a0
27 changed files with 244 additions and 845 deletions

View File

@@ -31,6 +31,37 @@ window.html = function html(elementString) {
return doc.body.firstChild;
}
window.util = {}
window.util.getColor = function(name) {
const rootStyles = getComputedStyle(document.documentElement);
const color = rootStyles.getPropertyValue(`--${name}`).trim();
if(!color) {
throw new Error("Color not found")
}
return color
}
window.util.observeClassChange = (el, callback) => {
if (!el || !(el instanceof Element)) {
throw new Error("observeClassChange requires a valid DOM element.");
}
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type === "attributes" && mutation.attributeName === "class") {
callback(el.classList);
}
}
});
observer.observe(el, {
attributes: true,
attributeFilter: ["class"]
});
return observer; // Optional: return it so you can disconnect later
}
/* JQUERY */