-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnouportal.js
82 lines (73 loc) · 2.73 KB
/
nouportal.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Function that fills the username and password fields
function fillCredentials() {
// Get the username and password
browser.storage.sync.get(["username", "password"]).then((res) => {
let username = res.username;
let password = res.password;
// Check if the username and password are not empty
if (username !== "" && password !== "") {
// Get the username and password fields
let usernameField = document.getElementById("USER_ID");
let passwordField = document.getElementById("USER_PASSWORD");
// Check if the fields exist
if (usernameField && passwordField) {
// Fill the username field if it's empty
if (usernameField.value === "") {
usernameField.value = username;
}
// Fill the password field if it's empty
if (passwordField.value === "") {
passwordField.value = password;
}
console.log(usernameField.value + " " + passwordField.value);
clickPortalLoginButton();
} else {
// If the fields do not exist, try again in 100ms
setTimeout(() => {
fillCredentials();
}, 100);
}
}
});
}
// Function that clicks the login button of the portal page
function clickPortalLoginButton() {
// Get all input elements
let portalLoginButton = document.querySelector('input[type="button"]');
// Check if there are any input elements
if (portalLoginButton) {
// Click the button
portalLoginButton.click();
} else {
// If there are no input elements, try again in 100ms
setTimeout(clickPortalLoginButton, 100);
}
}
// Function that clicks the login button of CLE
function clickCLELoginButton() {
// Get the login button
let CLELoginButton = document.getElementById("loginsaml");
// Check if the button exists
if (CLELoginButton) {
// Click the button
CLELoginButton.click();
} else {
// If the button does not exist, try again in 100ms
setTimeout(clickCLELoginButton, 100);
}
}
function runFunctions() {
// Check the current page URL
if (window.location.href.includes("ou-idp.auth.osaka-u.ac.jp/idp/")) {
fillCredentials();
} else if (window.location.href.includes("cle.osaka-u.ac.jp")) {
clickCLELoginButton();
}
}
// Call the appropriate function when the page loads
if (document.readyState === "complete" ||
(document.readyState !== "loading" && !document.documentElement.doScroll)) {
runFunctions();
} else {
document.addEventListener("DOMContentLoaded", runMyFunctions);
}