-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeground.js
178 lines (160 loc) · 5.56 KB
/
foreground.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
chrome.storage.local.get(
[
"preferred_fc",
"email",
"name",
"uid",
"vaccination",
"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8",
"declaration",
],
(result) => {
const topBtn = document.createElement("div");
topBtn.innerHTML = `
<button
id="top"
class="btn btn-rounded btn-pink"
style="position: fixed; bottom: 0; right: 0; display: inline-flex;"
>
<i class="fas fa-chevron-circle-up"></i>
</button>
`;
topBtn.onclick = () => {
document.querySelector(".card-body").scrollIntoView();
};
document.querySelector("body").appendChild(topBtn);
if ("scrollRestoration" in history) {
history.scrollRestoration = "manual";
}
const url = window.location.href;
if (url === "https://fcbooking.cse.hku.hk/") {
document.querySelector(`#${result.preferred_fc}`).click();
document.querySelector(".card-body").scrollIntoView();
} else {
document.querySelector("#Email").value = result.email;
document.querySelector("#FirstName").value = result.name;
document.querySelector("#MemberID").value = result.uid;
if (result.vaccination) {
document.querySelector("#vacine_t").checked = true;
} else {
document.querySelector("#vacine_f").checked = true;
}
if (result.q1) {
document.querySelector("#Q1_t").checked = true;
} else {
document.querySelector("#Q1_f").checked = true;
}
if (result.q2) {
document.querySelector("#Q2_t").checked = true;
} else {
document.querySelector("#Q2_f").checked = true;
}
if (result.q3) {
document.querySelector("#Q3_t").checked = true;
} else {
document.querySelector("#Q3_f").checked = true;
}
if (result.q4) {
document.querySelector("#Q4_t").checked = true;
} else {
document.querySelector("#Q4_f").checked = true;
}
if (result.q5) {
document.querySelector("#Q5_t").checked = true;
} else {
document.querySelector("#Q5_f").checked = true;
}
if (result.q6) {
document.querySelector("#Q6_t").checked = true;
} else {
document.querySelector("#Q6_f").checked = true;
}
if (result.q7) {
document.querySelector("#Q7_t").checked = true;
} else {
document.querySelector("#Q7_f").checked = true;
}
if (result.q8) {
document.querySelector("#Q8_t").checked = true;
} else {
document.querySelector("#Q8_f").checked = true;
}
if (result.declaration) {
document.querySelector("#dataCollection").checked = true;
} else {
document.querySelector("#dataCollection").checked = false;
}
const payment = document.createElement("div");
payment.id = "payment";
payment.classList.add(
"alert",
"alert-warning",
"d-flex",
"justify-content-center",
"col-12"
);
payment.innerHTML = `
<div class="row">
<div class="col d-flex justify-content-center">
<div class="card" style="width: 18rem;">
<div class="card-body d-flex align-items-center">
<span>
<h5 class="card-title">Protein 🍳</h5>
<p class="card-text">
I made GymEasy to streamline the cumbersome process of gym session bookings at HKU.
<br>
If you find it useful, please consider adding to my protein fund!
</p>
</span>
</div>
</div>
</div>
<div class="col d-flex justify-content-center">
<div class="card" style="width: 18rem;">
<a href="https://payme.hsbc/atiabbz" target="_blank">
<img src="https://raw.githubusercontent.com/atiabbz/HKU-GymEasy/master/images/hsbcpayme.png" class="card-img-top" alt="hsbcpayme">
</a>
<div class="card-body d-flex justify-content-center align-items-center">
<span class="font-monospace">→ </span>
<a href="https://payme.hsbc/atiabbz" target="_blank" class="btn btn-danger">
HSBC PayMe
</a>
<span class="font-monospace"> ←</span>
</div>
</div>
</div>
<div class="col d-flex justify-content-center">
<div class="card" style="width: 18rem;">
<a href="https://qr.alipay.hk/28100401012kfekjs4lin5lx86" target="_blank">
<img src="https://raw.githubusercontent.com/atiabbz/HKU-GymEasy/master/images/alipayhk.png" class="card-img-top" alt="alipayhk">
</a>
<div class="card-body d-flex justify-content-center align-items-center">
<span class="font-monospace">→ </span>
<a href="https://qr.alipay.hk/28100401012kfekjs4lin5lx86" target="_blank" class="btn btn-primary">
AlipayHK
</a>
<span class="font-monospace"> ←</span>
</div>
</div>
</div>
</div>
`;
document
.querySelector("#gCaptcha")
.insertAdjacentElement("beforebegin", payment);
document.querySelector("#sbmtBtn").removeAttribute("disabled");
if (url.includes("SignUpPS")) {
document.querySelector('label[for="dataCollection"]').scrollIntoView();
} else {
document.querySelector("#CenterID").focus();
}
}
}
);