mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
63 lines
1.5 KiB
Django/Jinja
63 lines
1.5 KiB
Django/Jinja
{% if TAIGA_OIDC_ENABLED | bool %}
|
|
(function () {
|
|
const hiddenLabelPatterns = [
|
|
/^or login with$/i,
|
|
/^forgot it\?$/i,
|
|
/^not registered yet\? create your free account here$/i,
|
|
];
|
|
|
|
function hideElement(element) {
|
|
if (!element) {
|
|
return;
|
|
}
|
|
element.style.setProperty("display", "none", "important");
|
|
}
|
|
|
|
function hideDefaultLoginForm() {
|
|
document.querySelectorAll("input").forEach((input) => {
|
|
const placeholder = (input.getAttribute("placeholder") || "").toLowerCase();
|
|
const isDefaultLoginField =
|
|
placeholder.includes("username") ||
|
|
placeholder.includes("password") ||
|
|
input.type === "password";
|
|
|
|
if (!isDefaultLoginField) {
|
|
return;
|
|
}
|
|
|
|
hideElement(input.closest("form") || input);
|
|
});
|
|
|
|
document.querySelectorAll("body *").forEach((node) => {
|
|
if (node.children.length > 0) {
|
|
return;
|
|
}
|
|
|
|
const text = (node.textContent || "").replace(/\s+/g, " ").trim();
|
|
if (!hiddenLabelPatterns.some((pattern) => pattern.test(text))) {
|
|
return;
|
|
}
|
|
|
|
hideElement(node);
|
|
});
|
|
}
|
|
|
|
function run() {
|
|
hideDefaultLoginForm();
|
|
}
|
|
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", run, { once: true });
|
|
} else {
|
|
run();
|
|
}
|
|
|
|
new MutationObserver(run).observe(document.documentElement, {
|
|
childList: true,
|
|
subtree: true,
|
|
});
|
|
})();
|
|
{% else %}
|
|
// Taiga OIDC is disabled, so no custom login UI cleanup is needed.
|
|
{% endif %}
|