-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
56 lines (51 loc) · 2.24 KB
/
content.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
let strc1 = document.querySelectorAll('.answerline .hide');
strc1.forEach((element) => {
let answer = element.textContent.trim();
const inputField = document.createElement('input');
inputField.type = 'text';
inputField.style.textAlign = 'center';
inputField.innerText = 'Center Text';
inputField.style.borderWidth = '3px';
inputField.style.backgroundColor = 'transparent';
inputField.style.fontSize = '17';
inputField.style.color = 'rgba(128, 128, 128)';
inputField.addEventListener('input', () => {
const inputValue = inputField.value.trim();
if (inputValue === answer) {
inputField.style.borderColor = 'rgb(171, 255, 193)';
} else if (inputValue.length === answer.length) {
inputField.style.borderColor = 'rgb(247, 255, 171)';
} else if (inputValue === '') {
inputField.style.borderColor = 'initial';
} else {
inputField.style.borderColor = 'rgb(255, 171, 171)';
}
});
element.parentNode.insertBefore(inputField, element);
});
let strc2 = document.querySelectorAll('.hide.toggle .answerline');
strc2.forEach((element) => {
let answer = element.textContent.trim();
const inputField = document.createElement('input');
inputField.type = 'text';
inputField.style.textAlign = 'center';
inputField.innerText = 'Center Text';
inputField.style.borderWidth = '3px';
inputField.style.backgroundColor = 'transparent';
inputField.style.fontSize = '17';
inputField.style.color = 'rgba(128, 128, 128)';
inputField.addEventListener('input', () => {
const inputValue = inputField.value.trim();
if (inputValue === answer) {
inputField.style.borderColor = 'rgb(171, 255, 193)';
} else if (inputValue.length === answer.length) {
inputField.style.borderColor = 'rgb(247, 255, 171)';
} else if (inputValue === '') {
inputField.style.borderColor = 'initial';
} else {
inputField.style.borderColor = 'rgb(255, 171, 171)';
}
});
element.parentNode.parentNode.querySelector('.toggle .answerline').after(inputField);
element.parentNode.parentNode.querySelector('.toggle .answerline').remove()
});