better explanation
All checks were successful
/ build (push) Successful in 2m55s

This commit is contained in:
Ruben 2025-07-23 20:21:46 -05:00
commit ffd8927fed
Signed by: sneexy
GPG key ID: 8ECFA045E63BC583

View file

@ -6,10 +6,10 @@
// try and see if user has a session
const hasAuthToken = localStorage.getItem('account');
// check if we have visitor-root
// check if we have visitor-root-*
const isWelcomePage = document.querySelector('[class*="visitor-root-"]');
// compared both values to execute
// compare both values to execute
const isLoggedOut = !hasAuthToken && isWelcomePage;
if (isLoggedOut) {
@ -19,10 +19,10 @@
}
}
// watch and wait to execute once sharkey modifies the html element
// we watch and wait until modifications to the html document happen first to execute, otherwise it doesn't work
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
// check if html element changes or elements were added
// execute once both html class and new elements are loaded in
if ((mutation.type === 'attributes' && mutation.attributeName === 'class') ||
mutation.type === 'childList') {
roundifyLoggedOut();
@ -30,7 +30,7 @@
});
});
// observe both html classes and body elements for changes
// observe both html classes (modified once sharkey initializes) and body elements for changes (when visitor-root-* loads in)
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class'],