-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (39 loc) · 1.64 KB
/
app.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
document.addEventListener("DOMContentLoaded", initCode());
function initCode() {
/****************************************** Variables ******************************************/
const sortDiv = "#module-page > div:nth-child(4)"; // location of the button
const finished = ".btn-light.btn-sm" // finished modules
/****************************************** Methods ******************************************/
function hider() {
const element = document.querySelector(finished);
if (element !== null) {
let parent = element;
for (let i = 0; i < 6; i++) {
parent = parent.parentNode;
}
if (parent !== null) {
parent.remove();
}
}
requestAnimationFrame(hider);
}
/****************************************** Label ******************************************/
// Create label element
const label = document.createElement("label");
label.className = "btn btn-light";
// Create input element
const input = document.createElement("input");
input.setAttribute("type", "radio");
input.setAttribute("name", "status");
input.setAttribute("value", "unfinished");
// Create text node for the label
const text = document.createTextNode("Unfinished");
// Append the input and text to the label
label.appendChild(input);
label.appendChild(text);
// Append the label to the desired location in the DOM
const parent = document.querySelector(sortDiv);
parent.appendChild(label);
// Attach event listener to the label
label.addEventListener("click", hider);
}