mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-07-26 10:11:10 +02:00
39 lines
1.1 KiB
Django/Jinja
39 lines
1.1 KiB
Django/Jinja
(function() {
|
|
const logoutUrlBase = 'https://auth.cymais.cloud/realms/cymais.cloud/protocol/openid-connect/logout';
|
|
const redirectUri = encodeURIComponent('https://cymais.cloud');
|
|
const logoutUrl = `${logoutUrlBase}?redirect_uri=${redirectUri}`;
|
|
|
|
// Check if a string matches logout keywords
|
|
function matchesLogout(str) {
|
|
return str && /logout|log\s*out|abmelden/i.test(str);
|
|
}
|
|
|
|
// Check if any attribute name contains "logout" (case-insensitive)
|
|
function hasLogoutAttribute(el) {
|
|
for (let attr of el.attributes) {
|
|
if (/logout/i.test(attr.name)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Find all elements
|
|
const allElements = document.querySelectorAll('*');
|
|
allElements.forEach(el => {
|
|
if (
|
|
matchesLogout(el.getAttribute('name')) ||
|
|
matchesLogout(el.id) ||
|
|
matchesLogout(el.className) ||
|
|
matchesLogout(el.innerText) ||
|
|
hasLogoutAttribute(el)
|
|
) {
|
|
el.style.cursor = 'pointer';
|
|
el.addEventListener('click', function(event) {
|
|
event.preventDefault();
|
|
window.location.href = logoutUrl;
|
|
});
|
|
}
|
|
});
|
|
})();
|