Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var isHidden = false;
- function hideAnswers(hidden) {
- console.log('Answers will now be hidden:', hidden);
- var elements = document.getElementsByClassName("outcome");
- for (let i = 0; i < elements.length; i++) {
- elements[i].style.display = hidden ? "none" : "block"
- }
- }
- let child = document.createElement('button');
- let body = document.getElementsByTagName('body')[0];
- let timeout = document.createElement('input');
- timeout.style = child.style = "background-color: #4CAF50;position: fixed; top: 100px; left: 29px; z-index: 1000000;";
- child.innerText = "Toggle Answers";
- child.id = 'toggle-btn';
- body.appendChild(child);
- timeout.style.backgroundColor = undefined;
- timeout.value = 0;
- timeout.style.top = "125px";
- body.appendChild(timeout);
- child.onclick = () => {
- let btn = document.getElementById('toggle-btn');
- // btn.value = !btn.value;
- isHidden = !isHidden;
- if (isHidden) {
- btn.style.backgroundColor = '#4CAF50';
- } else {
- btn.style.backgroundColor = "rgb(175 76 76)"
- }
- hideAnswers(isHidden);
- if (isHidden == false && timeout.value != 0) {
- setTimeout(()=> child.onclick(), timeout.value);
- }
- }
- child.onclick();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement