-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbody.html
More file actions
69 lines (59 loc) · 1.96 KB
/
Copy pathbody.html
File metadata and controls
69 lines (59 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script>
function oidcRedirect() {
const qs = new URLSearchParams(window.location.search.substring(1));
qs.delete('oidc');
const roomname = encodeURIComponent(window.location.pathname.substring(1));
window.location = `/oidc/auth?roomname=${roomname}`;
try {
// remove react from DOM to prevent UI distortion
document.all.react.remove();
} catch (e) {
// Do nothing if the React element cannot be removed
}
}
function handleButton(button) {
let labelKey;
try {
labelKey = Object.values(button)[0].return.memoizedProps.labelKey;
} catch (e) {
// Do nothing if the labelKey cannot be accessed
}
if (labelKey === "dialog.login") {
oidcRedirect();
} else if (labelKey === "dialog.IamHost") {
button.onclick = oidcRedirect;
}
}
let loggedModalButtonNotFound = false;
let loggedErrorIntercepting = false;
function interceptLoginRequest() {
const observer = new MutationObserver((mutationsList, observer) => {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
const button = document.getElementById("modal-dialog-ok-button");
if (button) {
handleButton(button);
observer.disconnect(); // stop observing after finding the button
break;
} else if (!loggedModalButtonNotFound) {
loggedModalButtonNotFound = true;
}
}
}
});
observer.observe(document.body, { childList: true, subtree: true });
}
try {
interceptLoginRequest();
} catch (e) {
if (!loggedErrorIntercepting) {
loggedErrorIntercepting = true;
}
}
</script>
</head>
</html>